224. Single element in sorted array
Given an array nums sorted in non-decreasing order. Every number in the array except one appears twice. Find the single number in the array.
Example 1:
Input :nums = [1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6]
Output:4
Explanation: Only the number 4 appears once in the array.
Example 2:
Input : nums = [1, 1, 3, 5, 5]
Output:3
Explanation: Only the number 3 appears once in the array.
Now Your Turn!
Pick the correct output for the given inputInput :nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- n == nums.length
- 1 <= n <= 104
- -104 <= nums[i] <= 104