Problems > First Repeated Value

First Repeated Value

Difficulty: 1000 2000 ms 128 MB

implementation

Scanning left to right, print the first value that has already appeared earlier. If all values are distinct, print NONE.

Input: the first line has an integer N; the second line has N integers separated by spaces.

Output: the first repeated value, or NONE.

Constraints:

  • 1 ≤ N ≤ 2000
  • −109 ≤ ai ≤ 109

Sample Tests

Input 1
5
2 5 3 5 2
Output 1
5
Input 2
3
1 2 3
Output 2
NONE

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.