CT21802

Alaric's Copper stamps

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Legend says the vault under the maple sugarbush of Saprun opens only for a perfect tally of stamps. Alaric 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 <= 412; -1000000 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 395 -590155 -812519 -814783 -392615 -833308 -971865 -254672 -381852 -499939 -329938 -251258 -170278 -298169 -565187 -56239 -462716 -961065 -666766 -455948 -200705 -539359 -336634 -336740 -647331 -178769 -917512 -721380 -3101 -985790 -108283 -537537 -603851 -522257 -944708 -47652 -424452 -206165 -801673 -398695 -205487 -88532 -714092 -341956 -858067 -573782 -398470 -589249 -546933 -758276 -344763 -530413 -765129 -882933 -988454 -847010 -835862 -954064 -948502 -750102 -530355 -593508 -562430 -201558 -7439 -488452 -238421 -379731 -909303 -741523 -903097 -437673 -731085 -443633 -86954 -339018 -654779 -435751 -388038 -102418 -464585 -858831 -388305 -773401 -7567 -420077 -839449 -720057 -957412 -780663 -121850 -638836 -51150 -524161 -766605 -509810 -462847 -94224 -974369 -746295 -383884 -149570 …
Output: -527056

Example 2:

Input: 289 -803228 -832691 -477122 -958351 -730278 -712062 -439391 -810429 -768404 -930252 -973751 -493971 -538912 -140279 -931085 -295620 -527220 -698723 -851018 -783519 -545419 -779175 -648890 -320351 -178456 -128646 -778400 -255505 -907829 -950465 -247356 -598925 -16517 -801895 -70357 -538751 -134375 -964441 -98521 -264434 -248853 -169494 -535528 -239857 -393454 -452663 -16926 -865151 -141891 -743967 -586408 -841397 -641643 -593144 -382634 -768026 -63480 -673820 -227844 -140643 -619065 -917759 -396040 -196113 -889506 -346667 -873432 -263539 -193395 -188875 -976774 -516924 -593628 -634865 -507812 -397703 -678112 -734437 -705385 -20668 -278955 -50813 -782818 -687490 -892501 -808965 -564850 -685345 -637583 -241113 -541436 -950741 -753807 -659111 -99215 -462762 -416363 -924060 -552873 -558398 -570…
Output: -962147

Example 3:

Input: 277 -517145 -473373 -697924 -494025 -76601 -613322 -948527 -296661 -165213 -899020 -679938 -294902 -775056 -906030 -160853 -905376 -165467 -132030 -709515 -673951 -892013 -311413 -34727 -595095 -99601 -259421 -827308 -835444 -841471 -270122 -197108 -340147 -319498 -591833 -174140 -340507 -135263 -718640 -977949 -746758 -311508 -396366 -379759 -791932 -404982 -170715 -82812 -633171 -289860 -276545 -545931 -388036 -75482 -674577 -340317 -615106 -634081 -39106 -25134 -892841 -230900 -97124 -328263 -731617 -108704 -967480 -533802 -923788 -488350 -743309 -706621 -87428 -56615 -398359 -666020 -680161 -735949 -108613 -581637 -934076 -946606 -845138 -110814 -449942 -364272 -568251 -48344 -732678 -958101 -990347 -700163 -505763 -103556 -699886 -277835 -127754 -452141 -369518 -276691 -18150 -405600 …
Output: -328263

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Alaric's Copper stamps - EASY Coding Problem | CodeTikki