Unique Element In Sorted Array
Nobita wants to impress Shizuka by correctly guessing her lucky number. Shizuka provides a sorted list where every number appears twice, except for her lucky number, which appears only once. Your task is to find this unique lucky number for Nobita.
Example:
Input:
T = 2
N = 7
list = [1, 1, 2, 2, 3, 4, 4]
N = 5
list = [5, 5, 7, 8, 8]
Output:
3
7
Explanation:
For the first test case, the number 3 appears only once in the list, whereas others appear twice. Similarly, for the second test case, the number 7 is the lucky number.
Constraints:
- 1 <= T <= 5
- 1 <= N <= 105
- 0 <= data <= 109 where ‘data’ is the value of elements in Shizuka’s list.
- Time Limit: 1 sec
Note:
You do not need to print anything; the output should be returned by implementing the function provided.
Be the first one to answer
Add answer anonymously...
Top MAQ Software Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in MAQ Software Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app