CT27058

The First Repeat Beneath Duskwood

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The council of the frontier camp of Duskwood pays by the answer, and Hugo intends to earn it. First: the full register of readings. 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 <= 607; -1000000 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 7 -395736 -262188 -933141 -890236 -466651 -534505 -648559
Output: -1

Example 2:

Input: 380 -108454 -542519 -829914 -330021 -967971 -582908 -335367 -850960 -374396 -587894 -38932 -182243 -374847 -200638 -464639 -433447 -677284 -284162 -49513 -168314 -532134 -853643 -285373 -331723 -425204 -874018 -57318 -973323 -473401 -745270 -848878 -851649 -877497 -846960 -72139 -280150 -707043 -449420 -564486 -554857 -100452 -379759 -98812 -437198 -277008 -337928 -15476 -336452 -128669 -794401 -93943 -242836 -757876 -315112 -145234 -639257 -923148 -952431 -337663 -443325 -706801 -230178 -888808 -667700 -499592 -801103 -933835 -552442 -942497 -142627 -567647 -550104 -668379 -851360 -508352 -569308 -751682 -422627 -525505 -825778 -822211 -678566 -191329 -196368 -420868 -966579 -206026 -550541 -710040 -343599 -842106 -470289 -492078 -541609 -581326 -85460 -274304 -548297 -640588 -446553 -143…
Output: -189357

Example 3:

Input: 518 -483734 -546664 -446700 -370090 -977060 -480307 -164484 -657914 -90372 -540569 -631195 -745441 -435136 -988834 -414322 -454708 -117649 -869410 -550467 -199189 -128290 -38781 -58368 -158530 -605320 -309974 -885456 -127135 -839518 -887396 -672201 -281281 -581228 -170981 -674803 -507331 -745748 -487404 -861134 -397061 -999895 -994953 -789653 -889304 -835246 -890479 -515475 -85269 -230797 -324600 -640881 -871569 -208944 -349991 -628891 -315236 -300242 -883574 -152385 -965104 -408746 -573642 -236219 -40850 -468763 -771806 -173715 -887169 -660491 -936498 -635973 -200378 -570680 -413167 -511585 -372339 -450509 -652853 -461377 -295782 -308523 -305255 -118124 -130605 -337599 -554195 -363959 -464976 -134085 -510235 -936108 -538738 -582595 -113478 -28374 -80975 -800537 -827124 -425482 -589025 -12…
Output: -128290

Constraints:

1 <= n <= 607; -1000000 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Loading...
Test Cases:No test cases
No test cases available.
The First Repeat Beneath Duskwood - EASY Coding Problem | CodeTikki