class Solution {
public:
int findDuplicate(vector<int>& nums) {
if(nums.size()<2) return nums[0];
int n=nums.size();
int fast=0,slow=0;
do
{
slow=nums[slow];
fast=nums[fast];
fast=nums[fast];
}while(fast!=slow);
slow=0;
while(fast!=slow)
{
fast=nums[fast];
slow=nums[slow];
}
return slow;
}
};
标签:nums,重复,Solution,寻找,LeetCode,287
From: https://www.cnblogs.com/tangxibomb/p/17559517.html