Array : Element appears once in sorted array

Find the element that appears once in a sorted array where all other elements appear twice one after another. Find that element in 0(logn) complexity.

Input: arr[] = {1, 1, 3, 3, 4, 5, 5, 7, 7, 8, 8}
Output: 4

Solution :


Test Cases:

1) {}

2) {1,1,5,7,7}

3) {1,1,2,2,7}

4) {2,3,3,5,5,7,7}




Comments

Popular posts from this blog