Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
find duplicate in O(n)
int findDuplicate(vector<int>& nums) { int n=(int)nums.size(); vector<int>v(n+1); fill(v.begin(),v.end(),-1); for(int i=0;i<n;i++) { if(v[nums[i]]!=-1) { return nums[i]; } else { v[nums[i]]++; } } return -1; }
run
|
edit
|
history
|
help
0
merge without extra space Gap method ALgorithm
dsu on tree (http://codeforces.com/contest/208/problem/E)
a simple tuple implementation
D. Traveling Graph
cppbasic
Float
Cley
sd5
How to make stupid to my friend?
23