Ad
  • Custom User Avatar

    len(set(arr)) is a clever expression.
    Congrats!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Interesting and pretty logical solution. Congrats!

  • Custom User Avatar

    Underrated Solution.

  • Custom User Avatar

    I think sorting is too costly for this problem. Am I wrong?

  • Custom User Avatar

    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

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    Can't Submit