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
return ends a function, you would only go to the next line if it didnt return
This comment is hidden because it contains spoiler information about the solution
Оставшаяся часть кода после return не будет выполнятся, программа выйдет из функции, поэтому это работает без написания else
its more efficient. however you end up relying on built in functions
This comment is hidden because it contains spoiler information about the solution
It doesn't, but: "You may assume the parameter is non-negative."
return -1 is ours else
How will it work for negative integer values?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Seems like your N's is to small to see benefits from Counter. Your solution is O(n^2), so for large N, your solution will be much slower than op's solution (wich is O(n))
Loading more items...