Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
It's 7 Kyu
@Wei-LiangChew I'm a little late but then the while loop will iterate over with n - 1 = 8 (and so on)
But what if the largest 5-digit number in
digits
doesn't start with 9?I agree with this. This is also related to other suggestions about performance.
Some solutions float to the top as "best practice" or "clever" even though they have clear issues. Negative flags could address this.
Great Job, I just started to learn regex, and I find it really useful ( rather than iterate over each caracter and check), it could be a little faster if you replace .sort.pop for .max, I'm still not sure how regex does it, because in order to find all chunks starting with 9 and 4 more digits it still needs to iterate over all the array, so Im not sure why my solution is slower, maybe because the regex is executed in a binary library rather than interpreted like ruby ?
The same came into my mind when implemented it.
Thanks pal, I really didn't know that.