[Static Linkedlist] Very Easy Python Code

  • 0

    just use value as next
    if there is a cycle , that means there is same value

    class Solution(object):
        def findDuplicate(self, nums):
            next = 0
            while nums[next] != -1:
                nums[next], next = -1, nums[next]
            return next

Log in to reply

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