In this problem, nums[a] = b can be seen as a.next = b, the the problem is exactly the same as Linked List Cycle II which finds the node that cycle begins.
def findDuplicate(self, nums): slow = fast = finder = 0 while True: slow = nums[slow] fast = nums[nums[fast]] if slow == fast: while finder != slow: finder = nums[finder] slow = nums[slow] return finder
"Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive)"
So the circle cannot start at position 0.
integer is larger than 0
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.