Why is no one handling the case of repeated numbers?


  • 0
    D

    The problem description doesn't mention that there won't be any repeats, for example:

    [1,2,3,1,1]
    

    but none of the posted solutions (in this forum) seem to be handling that case. It seems that the test-cases are missing repeated numbers.


  • 0

    What do you mean the solutions don't handle it? Do any of them give you a wrong answer for that input?


  • 0
    D

    @StefanPochmann oops, I missed the fact that the O(1) space solutions all check a[i] != a[a[i]] before swapping them both.
    My bad :-/


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.