CT28740

The First Repeat of the Wistful barrels

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Every season at the moonlit lagoon of Selene, someone must reorganize the archive shelves. This year the task falls to Yash, armed only with the barrels register. 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 <= 653; -1000000 <= a[i] <= 1000000000; answers fit a signed 64-bit integer.

Example 1:

Input: 371 -45109 933698 857235 183413 -244905 -66064 521741 919701 -117016 -940048 188123 -169484 -169187 918978 891907 554362 -574260 -367771 -478567 -331614 -160262 -380945 435744 -303775 121783 -413048 930024 924000 -13226 -871624 -103287 217367 -359486 -771282 -810761 -544540 -428147 -928069 -830363 668841 -239285 834947 -562991 -651116 400888 533900 -105382 412385 -504820 -173960 -720980 292146 -192179 397529 -744867 -471219 154901 568112 -836132 519903 465660 -433666 724801 87620 214624 -605258 425651 790554 -999037 885327 755996 892211 -633853 -279533 -425757 394849 929954 -943192 107404 221202 914796 -987039 466962 -482043 650372 733855 -968752 -984179 856615 -464157 -756459 -672794 -602358 -502524 432067 -826627 580977 -558121 797357 -978049 489273 387011 845467 325749 427401 -470965 -1…
Output: -45109

Example 2:

Input: 494 129515 154803 -393681 -430291 184037 -485482 789736 893326 95384 -158231 892935 -285833 -626304 -402301 524209 144970 454652 -714543 -501367 -831593 161000 210842 606040 128732 475404 -979034 -242633 -730452 328121 -944836 -79225 652924 -371133 -217894 500437 232753 -282065 -288840 127174 -889058 -891952 -499407 -163251 255115 -173513 309671 595972 -582277 874335 273036 -854912 -627058 -354448 -941380 988433 -378571 490114 -450672 627078 -388783 -396977 661245 374510 915580 -974148 -424012 827031 821908 -117040 -26963 -536930 -199130 167507 -84973 -877314 690617 -166437 400047 248755 201867 254531 -621437 -778056 -518090 477922 -877046 -788973 -514921 -303961 -106767 450302 -406797 -556674 874344 -916233 692924 909648 -131060 957373 100585 -491986 -288198 17697 698918 -825137 171120 -3…
Output: -999084

Example 3:

Input: 244 -414875 787061 -605211 46199 -321929 395287 -828453 -828697 669956 242554 183170 -530377 -28760 410360 988329 119387 500529 -65296 491300 -909557 -984308 -791044 -470966 -523671 977564 -633232 602979 -257305 117249 912117 435450 -704268 -79468 -218100 -266649 330945 985512 -756337 -203238 -246225 -194849 687788 -577224 -128247 398702 779687 3115 101247 -210360 653632 -654963 728591 799308 725840 833761 -228274 980610 864719 -917427 -252617 -141554 945793 678065 -542925 -741007 -646038 -586636 63205 51353 194054 120436 -250050 922147 -154186 262599 -16083 -722693 803181 620562 149349 325838 -212542 631428 567573 -792482 -787222 358635 612474 939684 604363 -232507 -290422 943098 517832 -341545 314283 612674 653306 -513643 663879 -938726 -366741 733158 436572 489182 -255088 930564 244853 …
Output: -513643

Constraints:

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

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