CT27041

Chavi's Ledger of readings

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Legend says the vault under the forest village of Briarthorn opens only for a perfect tally of readings. Chavi means to find out. Task: Read n integers and print the first value that appears twice (the value whose second occurrence has the smallest index). If all are distinct print -1. Input format: First line: n. Second line: n space-separated integers. Output format: Print the first repeated value, or -1. Constraints: 1 <= n <= 290; 0 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 242 10 0 8 6 2 9 4 4 10 6 8 4 7 9 7 6 10 10 2 9 9 10 1 4 1 1 7 9 2 3 9 3 6 1 3 5 2 0 10 5 2 10 4 3 10 0 4 10 8 1 5 2 7 7 4 5 6 9 9 0 8 0 2 4 5 2 2 4 0 4 7 1 7 8 7 2 8 0 5 3 10 0 10 9 7 0 7 5 0 10 2 5 3 9 3 5 4 1 10 2 1 4 5 3 2 3 5 5 6 6 5 8 0 10 7 2 4 4 10 0 3 0 4 8 10 6 0 2 5 6 8 0 0 9 4 10 9 6 3 4 0 4 4 4 10 7 6 3 9 2 10 3 10 6 0 7 1 7 7 1 1 1 2 0 1 5 8 8 4 0 6 8 3 6 0 9 0 2 3 0 4 7 6 5 9 9 6 3 8 4 1 2 1 4 8 8 9 7 9 9 6 3 8 3 6 0 2 7 4 6 5 4 1 7 5 7 3 3 4 1 10 9 8 1 6 7 8 4 6 0 0 7 4 7 5 5 10 8 6 0 6 10
Output: 4

Example 2:

Input: 133 4 4 2 0 2 10 6 4 4 10 10 8 10 6 9 9 5 9 5 1 1 9 8 0 3 10 5 6 2 1 7 9 4 6 2 3 8 8 9 5 1 3 8 4 0 3 2 1 4 1 10 3 9 0 2 4 8 7 8 7 2 6 9 0 4 2 1 6 0 4 1 8 6 10 7 8 2 1 6 9 7 4 0 4 3 10 2 1 4 10 10 7 1 4 9 6 2 3 10 1 4 0 8 6 0 7 9 4 0 6 4 10 6 10 1 10 5 1 10 8 8 8 3 9 10 10 2 4 7 6 5 3 1
Output: 4

Example 3:

Input: 274 7 3 4 1 0 1 3 8 6 2 9 6 0 4 6 9 2 6 1 8 9 0 3 8 2 4 4 3 2 3 3 8 1 7 6 6 4 8 7 1 8 0 3 8 10 4 7 0 0 8 8 2 7 4 3 10 10 1 6 9 4 4 5 0 2 9 3 7 8 9 4 4 7 6 1 5 10 2 10 8 3 4 1 9 10 4 1 10 1 9 6 4 1 4 9 7 0 0 4 0 10 10 3 6 2 10 9 0 5 1 5 0 10 10 8 0 10 3 7 7 6 0 0 7 8 5 3 3 8 8 1 7 5 9 7 9 4 3 2 9 1 7 0 7 8 7 5 8 3 3 1 5 2 8 8 6 3 8 4 7 5 6 10 1 3 5 10 1 4 8 1 4 9 1 7 3 2 7 9 7 0 7 0 5 6 3 0 0 8 0 2 4 3 4 3 0 7 9 7 10 9 3 4 7 9 9 7 8 4 1 3 5 7 4 6 1 7 1 10 6 6 10 5 3 8 8 6 6 2 3 7 5 2 3 10 3 5 4 8 6 3 2 0 7 3 4 6 5 10 7 7 8 3 5 2 10 0 0 9 3 1 10 7 0 10 3 8 0 10 9 8 10 1 2
Output: 1

Constraints:

1 <= n <= 290; 0 <= a[i] <= 10; answers fit a signed 64-bit integer.

Loading...
Test Cases:No test cases
No test cases available.