top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Find the number occurring odd number of times in an array?

+1 vote
290 views

For eg. 1,4,6,7,3,1,4,7,3,1,6 (given array)

posted Dec 9, 2014 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
int OddOccur(int arr[], int ar_size)
{
     int i,out = 0;

     for (i=0; i < ar_size; i++)
     {
                out = out ^ arr[i];
     }

     return out;
}

main()
{
     int arr[] = { 1,4,6,7,3,1,4,7,3,1,6 };
     int n = sizeof(arr)/sizeof(arr[0]);
     printf("%d", OddOccur(arr, n));
}
answer Dec 9, 2014 by Sridharan P
Similar Questions
+3 votes

In an "N" element integer sorted array, a particular elements is repeating "(N/2)+1" times. How much time it take to find the repeating element.

+1 vote

Given an array of 1s and 0s which has all 1s first followed by all 0s. Find the number of 0s. Count the number of zeroes in the given array.

...