------
## 最终结论
```python
def findDuplicate(nums):
    # Step 1: Initialize the tortoise and hare
    tortoise = nums[0]
    hare = nums[0]

    # Step 2: Find the intersection point in the cycle
    while True:
        tortoise = nums[tortoise]
        hare = nums[nums[hare]]
        if tortoise == hare:
            break

    # Step 3: Find the entrance to the cycle
    tortoise = nums[0]
    while tortoise != hare:
        tortoise = nums[tortoise]
        hare = nums[hare]

    return hare

# Example usage:
print(findDuplicate([1, 3, 4, 2, 2]))  # Output: 2
print(findDuplicate([3, 1, 3, 4, 2]))  # Output: 3
```