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.
thx for askingI also have no idea why itd [0,0,0]
modulo operation was expensive isn't it? it can be done without using module operation at all..
The point was to hand-write a recursive function :)
Response from SleepyAsura [https://www.codewars.com/users/SleepyAsura]
I UNDERSTOOD!!!! I will explain:
[5, 4, 3, 2, 1] => Output [4, 3, 2, 1, 0] Let's say the first element is 5. We need to count how many elements on the right are smaller 5!
4, 3, 2, 1 < 5 !!! Therefore, we replace 5 with 4, since there are only 4 elements in the array that are less than five. Next we check 4 and etc.
I guess it's the overflow considerations?
This comment is hidden because it contains spoiler information about the solution
what is meant with the "worst case" ?
you can see his solution... there you will see why
impressive!
If the goal is to pass the test, that's fine. But this code cannot be considered best practice because it does not consider the worst case.
fyi ya can do (1..=n) instead (1..n + 1) to include the end of the range
10 points to Joh_Pot for the most vague explanation of the century.
well it's an
O(n)
solution and there is an obviousO(1)
solutionthat's why it does not deserve its insane 250 upvotes
still not clear
implied
Loading more items...