PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000096. Phần tử xuất hiện đúng một lần (Single Element in a Sorted Array)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Phần tử xuất hiện đúng một lần (Single Element in a Sorted Array)
Single Element in a Sorted Array
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
In a sorted integer array, exactly one value occurs once and every other value occurs exactly twice. Find the unique singleton value.
Input
The first line contains odd ; the second contains the sorted integers.
Output
Print the singleton value.
Subtasks
- Subtask 1 (20 points): ; is odd; ; non-decreasing; exactly one value occurs once, all others exactly twice.
- Subtask 2 (30 points): ; is odd; ; non-decreasing; exactly one value occurs once, all others exactly twice.
- Subtask 3 (50 points): ; is odd; ; non-decreasing; exactly one value occurs once, all others exactly twice.
Examples
Input
9
1 1 2 3 3 4 4 8 8
Output
2
Explanation
, , , and each appear twice; only occurs once. Output 2.