int DuplicatedNumber(int *a, int size){map hash;bool founddup = false;for(int i=0; i 0){founddup= true;break;}elsehash[a[i]]++;}
return founddup ? a[i] : -1; // return the duplicated value or -1 if not found}
No comments:
Post a Comment