Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Where are local variables stored in c?

981


What is static identifier?

1163


Tell us something about keyword 'auto'.

1010


What is memcpy() function?

1046


What is the deal on sprintf_s return value?

1066


Why is structure padding done in c?

1070


Why is c so powerful?

1061


what is the diffrenet bettwen HTTP and internet protocol

1785


what is recursion in C

1018


Explain how do you convert strings to numbers in c?

1019


‎How to define structures? · ‎

1029


What is the need of structure in c?

1047


What is #include called?

994


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

5893


Explain how do you use a pointer to a function?

1051