You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a sorted array of integers A where every element appears twice except for one element which appears once, find and return this single element that appears only once.
Input Format
The only argument given is the integer array A.
Output Format
Return the single element that appears only once.
Constraints
1 <= length of the array <= 100000
1 <= A[i] <= 10^9
For Example
Input 1:
A = [1, 1, 2, 2, 3]
Output 1:
3
Input 2:
A = [5, 11, 11, 100, 100]
Output 2:
5
*/
// we have two conditions here, if mid elemnt is at even index or mid element is at odd index, based on that the search space changes