CT27925

The First Repeat Beneath Balmcrest

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Baron runs the print shop at the cedar groves of Balmcrest. Today the books show a list of stamps, and the numbers must be worked out before sundown. 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 <= 588; -100 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 296 923 26 294 425 251 100 366 727 121 707 726 410 109 60 701 993 556 -43 -99 950 136 -38 -48 303 175 27 815 399 730 859 356 838 996 635 817 -33 -71 382 490 968 357 272 323 455 907 503 579 -41 940 12 133 246 658 146 273 461 265 -82 747 202 917 987 381 305 301 315 230 507 441 646 729 339 209 113 562 213 963 839 127 180 47 -55 229 -67 4 994 977 142 720 754 406 283 313 501 135 -30 956 370 589 181 635 478 28 426 821 46 -82 179 184 616 -83 427 311 204 864 123 469 534 224 531 735 236 485 130 548 633 781 304 -93 616 123 840 659 87 869 324 2 426 648 -45 964 644 159 179 88 837 87 347 565 952 889 9 987 138 488 583 137 643 -5 596 -46 358 22 593 161 186 425 336 287 94 944 247 75 885 69 175 672 -94 398 349 450 -63 724 236 959 496 513 411 228 204 842 463 674 751 -76 908 834 69 238 861 264 805 -40 520 18…
Output: 635

Example 2:

Input: 397 54 825 89 553 270 971 533 -26 962 993 350 745 60 302 400 868 -79 764 367 128 709 420 -19 384 -5 15 0 990 388 272 929 273 667 693 921 962 86 285 772 642 492 500 136 297 460 825 960 723 501 -47 412 -89 292 87 513 721 70 756 532 247 796 567 85 870 488 963 769 201 937 29 130 80 952 572 177 788 490 910 934 555 367 356 -97 -56 265 670 159 -12 514 6 634 411 314 14 503 40 224 349 624 358 553 473 737 468 971 962 230 949 712 822 523 276 876 -40 781 134 894 225 -19 493 149 802 982 901 414 183 -19 421 763 737 298 184 586 281 25 382 502 47 501 263 -13 235 522 364 868 752 303 386 509 356 105 215 236 182 -37 547 40 108 -40 996 484 620 166 524 897 466 703 533 514 318 597 424 475 246 -34 -94 598 446 493 132 734 213 160 833 687 939 8 670 539 291 88 681 826 196 420 -25 980 630 535 324 77 -13 648 95 681 1…
Output: 962

Example 3:

Input: 98 574 15 772 847 751 362 890 269 27 957 591 72 846 -64 773 100 683 421 356 174 165 784 661 687 864 72 213 778 303 -14 752 33 673 85 383 -66 894 755 411 859 -84 325 709 275 -76 545 467 701 72 697 2 746 434 -38 182 191 346 446 866 -20 103 159 603 423 620 939 494 123 789 480 470 771 -41 13 375 815 810 -88 980 -75 540 428 -85 -24 104 472 513 -14 486 529 672 550 971 386 432 -37 50 793
Output: 72

Constraints:

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

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