CT28190

Last barrels of Ishaan

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Ishaan inherited the aviary at the gristmill of Rye Hollow along with its curious bookkeeping system for barrels. 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 <= 547; 0 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 408 199 195 854 629 423 685 164 747 216 215 967 709 775 96 980 870 439 281 789 935 333 692 321 459 828 696 643 556 337 923 99 746 23 799 164 26 666 185 471 166 259 957 296 340 377 267 79 199 12 962 373 55 996 351 536 398 104 804 1 969 509 439 860 547 815 841 78 44 868 425 19 315 717 263 441 465 344 971 314 573 362 444 111 941 297 572 106 381 75 925 699 327 81 374 749 778 158 981 752 643 569 70 916 583 671 909 914 179 286 951 565 394 860 830 510 989 394 840 521 992 146 551 290 777 596 324 721 53 22 368 904 330 144 787 529 204 281 605 292 880 876 434 620 253 339 506 290 555 474 473 571 641 432 342 534 451 698 910 584 74 358 460 338 163 223 907 979 56 82 982 101 816 536 106 267 948 966 259 786 59 28 250 421 252 568 240 553 295 62 701 558 376 773 55 236 360 186 941 372 102 46 282 148 316 542 8…
Output: 164

Example 2:

Input: 93 562 286 53 148 988 789 173 74 928 909 503 502 264 939 772 936 233 148 210 819 976 811 722 179 839 293 911 622 9 482 800 812 605 976 470 663 139 189 122 394 531 412 571 611 520 934 514 403 230 28 771 288 679 502 612 890 174 471 479 88 424 776 57 580 226 836 163 314 879 854 18 637 884 38 374 523 428 763 300 783 312 227 114 258 512 238 178 986 412 189 527 497 735
Output: 148

Example 3:

Input: 174 883 208 961 166 782 14 530 71 208 305 679 390 812 375 759 425 854 719 841 370 119 567 650 439 605 662 381 185 305 586 94 710 73 109 770 532 476 174 313 492 873 700 968 210 290 904 991 807 744 792 193 941 733 581 360 24 750 39 598 792 398 618 489 696 875 829 585 976 969 850 436 434 126 667 677 51 468 466 995 518 701 797 32 835 230 183 601 378 648 515 897 208 745 874 336 312 751 135 465 576 185 271 403 897 395 714 181 517 915 74 400 529 124 163 338 614 99 54 420 933 72 584 363 876 881 883 902 315 667 13 949 10 26 975 774 498 378 378 895 911 691 298 416 272 885 173 134 289 51 160 836 411 716 83 871 598 213 371 349 424 278 358 803 346 476 49 563 963 243 947 1 232 810 185
Output: 208

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last barrels of Ishaan - EASY Coding Problem | CodeTikki