CT26237

Wren's First Repeat Ledger

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Wren the paymaster watches over the snowberry thicket of Winterholt's stores of readings. A careful computation stands between order and chaos. 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 <= 405; 0 <= a[i] <= 1000000000; answers fit a signed 64-bit integer.

Example 1:

Input: 114 296912 140375 297932 202969 862798 231499 394992 559647 430221 314602 231516 808958 591118 482537 209087 873238 852588 504715 478233 983487 60307 568227 301173 833461 373415 236276 442767 70976 177570 921343 340104 635364 935269 394428 415585 287354 515112 612982 36173 140516 515873 925580 997467 671812 156668 128631 952542 102864 191827 338952 320874 186407 629813 106760 746624 460933 939400 622452 45429 592072 342051 662177 372386 142560 227820 16764 212847 740169 677855 550729 953488 578077 77936 693558 359976 326470 796176 781953 820520 502885 604269 235720 287564 647624 998649 47128 558191 890037 876743 26225 437831 297406 369535 502338 292055 561692 194095 822315 715731 83022 641231 881266 370491 577218 647982 990970 620148 80187 239772 435191 6989 608901 102126 634494
Output: -1

Example 2:

Input: 79 772580 603427 579929 929072 856192 258345 736256 432089 314563 159322 905100 539318 290028 976021 226917 651548 469332 204192 724636 712463 885209 32807 872347 32866 276655 744676 741481 205503 509878 797237 464394 893878 645506 675345 581030 766634 900871 46722 863018 683758 383316 928552 464886 461092 846653 124801 611687 133017 638432 919140 779300 39115 548628 132359 61424 83362 757364 718032 871636 207012 876179 729355 365419 898165 518631 21385 428451 213998 617422 521227 99187 681008 806163 590750 332064 848361 229626 65356 651132
Output: -1

Example 3:

Input: 69 131902 952506 696258 708471 391298 657219 321352 568190 114194 803542 304185 28592 750136 25551 883302 689046 268119 896037 660210 85070 538732 68968 243669 367073 824111 225058 282699 314212 220264 109682 125094 336585 179934 261843 470357 464348 42604 488067 788005 499317 894966 875612 320617 438408 958124 476069 697247 657852 291776 168708 215195 711401 482523 5541 135862 778174 349596 298483 691017 139922 862173 294814 893147 437659 622490 464348 328803 14644 940420
Output: 464348

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Wren's First Repeat Ledger - EASY Coding Problem | CodeTikki