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.
len(set(arr)) is a clever expression.
Congrats!
This comment is hidden because it contains spoiler information about the solution
Interesting and pretty logical solution. Congrats!
Underrated Solution.
I think sorting is too costly for this problem. Am I wrong?
You are probably correct, you actually are, but in reality you do not need to care for that. You break out of the loop once you get to the fist smallest number that is not in the list, you won't keep looping O(n) where n is the whole range from min to max. I know that I am not considering the worst case scenario here but I was unable to think of a better algo! :D
I'm only commenting because I saw your comment elsewhere and I wanted to confront with your solution :D
You also get O(n) complexity where n is the length of array. So for small arrays with big differences between min and max you might be correct but for large arrays and small differences your solution will be mercilessly left behind. I don't know python very well but I'd assume that cost of removing an item from a list is disproportionately more costly than iterating an integer so without array size/number difference constrainst I wouldn't say either solution is better than the other.
This code is very clever but if distance between minimum and maximum is too big
while loop goes to o(n) complexity which is not good for this type of operation.
Can't Submit