← 返回 snowflake 的题目列表Find Unique Number in Consecutive Pairs
类型:online_judge
Given an integer array where each number appears twice except for one that appears only once, find the index of that unique number. The input is an integer array. The expected time complexity is O(log n).
Example 1:
Input: [1, 1, 2, 3, 3, 4, 4] Output: 2
Example 2:
Input: [2, 2, 3, 3, 4, 5, 5] Output: 4
Constraints:
The array length is between 3 and 10^5.
Each number is an integer between 0 and 10^9.
The array length is odd.
Note:
Use a binary search approach before resorting to linear time complexity.
Example
Input
[1, 1, 2]