For eg. 1,4,6,7,3,1,4,7,3,1,6 (given array)
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)); }
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.
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.