CT26378

Cressida Counts the scrolls

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

In the jade shrine of Serpentis, Cressida the chronicler keeps careful count of the scrolls. Map a faster supply route, every figure matters. 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 <= 755; -1000000 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 254 977372 791505 -744629 827916 976083 23303 547391 -2417 814067 -940819 -46132 -791884 -138719 362867 796541 78442 921678 -852903 -651242 954733 413441 327661 930809 202300 -232420 -567033 -331731 41691 671867 -604333 -512201 -502082 286576 757745 -269659 547784 -495322 926880 131149 -444641 -758519 -426647 -102365 -64118 404059 878607 -379532 935930 -795177 8024 -163400 687389 191449 -294527 -760960 -592579 -542642 471168 -202532 894541 822511 682619 585770 -307267 -617596 702752 443579 817426 -15302 -432401 183219 737987 -996462 733426 -674766 294209 38413 449735 761261 987951 878963 697473 60701 429415 145146 -842348 148131 390074 786608 581715 -924955 -100264 693194 -739429 603667 109964 -285716 869712 -179705 807266 -269444 740433 777200 -652544 707272 -525337 740617 473886 -43034 2…
Output: -1

Example 2:

Input: 404 -751035 -441906 323380 -806277 551429 -116918 -544297 637477 551916 -785852 212788 -354783 -428149 37975 -103346 710373 -155642 651354 562868 758583 -978346 910807 62095 -448196 -685112 845819 171734 -246492 -272965 -312541 -492351 312789 846078 778712 -106095 -897744 853948 983514 -800447 -375446 268082 312354 -9895 979306 -44544 -324629 -215515 -927986 763107 703501 20301 973175 695048 -260406 -998858 -570916 -892822 135927 -303308 606247 498561 487906 527984 103476 18614 -131899 715570 655732 301107 415300 -623751 222013 -998052 -859850 146679 -921684 142881 -496921 -880170 500415 -806711 477823 617782 469313 459312 -879655 472552 835815 147144 -668909 551783 36124 -519642 -724683 -963230 589987 -50513 865253 -199717 -774672 569405 -970144 -235423 318121 129942 -992010 -85352 -95634…
Output: -1

Example 3:

Input: 490 -84845 -618481 -450263 681414 258115 -733806 -491580 206781 -936410 -796323 -609265 -981215 93707 -336328 -267626 -151847 394424 -109578 -673932 171664 12287 -968565 -433226 -431733 -661375 526255 757448 734790 213141 -321025 954907 913581 696020 -529905 148651 -232580 41191 -445856 -11857 352080 -535124 -264448 352097 857833 -742681 -119269 -528860 -608064 -656685 -473518 44681 -496411 -287099 15936 -771721 -322372 -7047 113283 871531 728199 266182 452628 146601 16634 671223 522382 691517 -724741 -388922 -614181 120001 -484416 -927429 907383 -123326 -791428 -649336 -935307 -819590 148311 -110146 -761633 -370280 320926 829020 534479 274923 -514670 -609673 -550178 -499586 936418 -53456 940336 861187 -846601 810357 -638779 109779 277015 -539646 -188904 -452369 635561 975136 671108 804178…
Output: -733806

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Cressida Counts the scrolls - EASY Coding Problem | CodeTikki