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.
This comment is hidden because it contains spoiler information about the solution
Doesn't this code copy the list and result in more memory usage?
what's the last 10 for ?
step with reversing is not needed
why u all reversing array?LOL
An articulated and helpful comment, even if it were criticism, is always welcome, thanks! :)
parseInt isn't required here, (Integer. str) (with a space after the ., for some reason the space is getting removed in my comment) gets the job done. parseInt would avoid errors if there are any letters in the middle of the string, but knowing that the inputs will always be numerical makes this unneccessary. Not a criticism, just a comment
This comment is hidden because it contains spoiler information about the solution
Normally I'd say yes, giving
parseInt
a radix of 10 is best form. However, you really only have to worry about specifying a radix if the string could possibly have a leading"0x"
or"0"
. E.g.Both of those are impossible in this case: we know that the string is a number in string form and the digits are sorted in descending order, so it can't possibly begin with
"0x"
or"0"
(unless the number is 0, and then the radix is irrelevant).I prefer
+n
anyway in most cases, because you can test that the result isn'tNaN
.parseInt
andparseFloat
provide no error handling whatsoever.This comment is hidden because it contains spoiler information about the solution