Find the Duplicate Number Solutions in PythonNumber 287Difficulty MediumAcceptance 55.6%Link LeetCodeOther languages C++, GoSolutionsPython solution by haoel/leetcode# the same as linked list cycle problemdef findDuplicate(self, nums): if len(nums) <= 1: return -1 slow, fast = nums[0], nums[nums[0]] while slow != fast: slow = nums[slow] fast = nums[nums[fast]] fast = 0 while slow != fast: slow = nums[slow] fast = nums[fast] return slow# the same as linked list cycle problem def findDuplicate(self, nums): if len(nums) <= 1: return -1 slow, fast = nums[0], nums[nums[0]] while slow != fast: slow = nums[slow] fast = nums[nums[fast]] fast = 0 while slow != fast: slow = nums[slow] fast = nums[fast] return slow