Given an array of numbers, except for one number all the
others occur twice. Give an algorithm to find that number
which occurs only once in the array.
Answer Posted / guest
int arr[n]; //n' numbers
for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
{ if ( (a[i]==a[j])&&i!=j ) break; //ITS NOT THE NUM
if ( (a[i]!=a[j])&&j==n-1) return i; //IT IS!!
return -1; //IF THERE IS NO SUCH NUMBER...
| Is This Answer Correct ? | 3 Yes | 7 No |
Post New Answer View All Answers
Where are local variables stored in c?
What is static identifier?
Tell us something about keyword 'auto'.
What is memcpy() function?
What is the deal on sprintf_s return value?
Why is structure padding done in c?
Why is c so powerful?
what is the diffrenet bettwen HTTP and internet protocol
what is recursion in C
Explain how do you convert strings to numbers in c?
How to define structures? ·
What is the need of structure in c?
What is #include called?
Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon
Explain how do you use a pointer to a function?