Find the element that appears once in sorted array
Submissions: 15218   Accuracy:

51.1%

  Difficulty: Basic   Marks: 1

Given a sorted array A, size N, of integers; every element appears twice except for one. Find that element in linear time complexity and without using extra memory.

Input:
The first line of input consists of T, the number of the test cases. T testcases follow.
Each testcase contains two lines of input.
The first line of each test case contains the size of the array, and the second line has the elements of the array.

Output:
For each testcase, in a new line, print the number that appears only once in the array.

Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 107
0 ≤ A[i] ≤ 1017

Example:
Input:
1
11
1 1 2 2 3 3 4 50 50 65 65

Output:
4

** For More Input/Output Examples Use 'Expected Output' option **

Author: kartik


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.