CT28275

Orin's scrolls Reckoning

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Orin inherited the timber yard at the clockwork quarter of Gearford along with its curious bookkeeping system for scrolls. Time to make sense of it. 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 <= 414; -1000000 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 41 -975328 -646800 -855048 -482294 -643935 -443060 -818031 -246631 -243141 -865991 -195255 -842322 -418527 -225588 -642860 -108059 -983600 -23752 -919355 -557248 -456615 -300030 -399743 -871833 -323344 -365601 -109803 -489055 -707996 -722251 -703257 -555087 -52487 -593422 -557248 -256355 -797498 -850479 -907381 -821745 -167232
Output: -557248

Example 2:

Input: 205 -944026 -962828 -662279 -845930 -656287 -376682 -141395 -372488 -678511 -846622 -328631 -915639 -335090 -865765 -457291 -919189 -954426 -703875 -898367 -86067 -816565 -566154 -458956 -83744 -576629 -69670 -13509 -162373 -397533 -747818 -959435 -619041 -570089 -90974 -94688 -575913 -611897 -485413 -578256 -216274 -445579 -946905 -419498 -879907 -643866 -408680 -660183 -879907 -913941 -203792 -154600 -186554 -496493 -556251 -164137 -268577 -404618 -653271 -236855 -900888 -509948 -656457 -497961 -42139 -802539 -711014 -178247 -668804 -139252 -721819 -918122 -761752 -135130 -249703 -778768 -210228 -402838 -4690 -802582 -35525 -281436 -132080 -358598 -968064 -663826 -652660 -296706 -487271 -891924 -421330 -53929 -323043 -650694 -293571 -481558 -894648 -232108 -670418 -676457 -834656 -993579…
Output: -879907

Example 3:

Input: 219 -485790 -51907 -225972 -627059 -952634 -956385 -350906 -646886 -889269 -691470 -371523 -453575 -635219 -45755 -49314 -602343 -782047 -341443 -223291 -180732 -172265 -587313 -158138 -184716 -122992 -51193 -19655 -36808 -31697 -137898 -611287 -787512 -368453 -881870 -835850 -701620 -78682 -710057 -29276 -204524 -645367 -380428 -890962 -500122 -499269 -705554 -99795 -673915 -562765 -610589 -871324 -789861 -865752 -395814 -850180 -770668 -688218 -577964 -451429 -281873 -591577 -86362 -98124 -104154 -100596 -641287 -671662 -409416 -541258 -487043 -88378 -87821 -897667 -724302 -498871 -775769 -162825 -262298 -693328 -883503 -459102 -756351 -897720 -405697 -88120 -44458 -148102 -571951 -674596 -608143 -223692 -669917 -854352 -730597 -689997 -151759 -437412 -832819 -962974 -33720 -147681 -7758…
Output: -1

Constraints:

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

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