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
Dynamic Programming For Combinatorics - 1
Income calculator
Kishan_template
RandomMessage
Policy based smart pointer
Visakh
srednie
顺序表的实现——静态分配
Precendence of Pointer Indirection Example
On Off