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