int DuplicatedNumber(int *a, int size)
{
map
bool founddup = false;
for(int i=0; i
{
founddup= true;
break;
}
else
hash[a[i]]++;
}
return founddup ? a[i] : -1; // return the duplicated value or -1 if not found
}
|
LET'S TALK TECHNICAL
This blog is intended to help people prepare for the job interviews and improve their analytical skills. We have posted difficult datastructures and algorithm questions and puzzles. Interview experiences section is for the people to post their interview experiences.Views expressed here are of their personal and the blog author doesn't take any responsibility for the same.
|
Categories
FollowersBlog Archive
Jobs
Find more freelance jobs
|
Saturday, January 19, 2008Find a repeated integer in array of size n?int DuplicatedNumber(int *a, int size) return founddup ? a[i] : -1; // return the duplicated value or -1 if not found
Subscribe to:
Post Comments (Atom)
|
Popular Posts
|
No comments:
Post a Comment