[python] beat 95% of users


  • 0
    Y
    class Solution(object):
        def findDuplicate(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            ptr=0
            while True:
                a=ptr
                ptr=nums[ptr]
                nums[a]=0
                
                if nums[ptr]==0:
                    return ptr
                    break
                ```

Log in to reply
 

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