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
How do I copy files?
Who developed c language?
how can I convert a string to a number?
What is extern storage class in c?
Explain what does the format %10.2 mean when included in a printf statement?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
difference between object file and executable file
What does 1f stand for?
What is the purpose of & in scanf?
What are multidimensional arrays?
Explain what are the standard predefined macros?
Why is %d used in c?
What are the two forms of #include directive?
What is realloc in c?
What are run-time errors?