Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Find the Duplicate Number in array of n+1 integers having elements from 1 to n
class Solution { public: int findDuplicate(vector<int>& nums) { int slow=0; int fast=0; while(1) { slow=nums[slow]; fast=nums[nums[fast]]; if(fast==slow) break; } slow=0; while(slow!=fast) { slow=nums[slow]; fast=nums[fast]; } return slow; } };
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
candies
https://codeforces.com/contest/449/problem/D (INCLuSION EXCLUSION principle)
4
Lotto random number game {modify}
Bad Code2
Let's Go!
Deque EvenOdd
Wipro Problem 2: determine count
algortym A*
float precision test
Please log in to post a comment.