CT27934

Last scrolls of Bhavi

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Legend says the vault under the valley of Misthollow opens only for a perfect tally of scrolls. Bhavi 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 <= 624; 0 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 467 294176 696371 263889 607918 206133 910079 47256 208106 856334 399177 446893 148687 679898 942400 839841 480505 686330 18917 818172 568570 511660 857974 392713 85084 422726 891711 577578 41377 273345 440263 778488 561443 221830 245745 847180 628031 623802 613610 27684 853900 648562 294634 941282 600814 487439 98455 120684 107971 911433 734073 771261 490057 136270 515328 851294 651880 614217 395308 862670 264333 589197 450377 848244 82048 319000 286507 194066 74320 170316 514866 983677 376922 382210 965702 538843 652248 776560 111756 327150 953880 751187 296630 236593 11476 511937 107802 800520 843731 164764 173453 312395 308739 38352 694740 515228 723528 922909 957211 215521 293172 92985 194242 289257 838349 416533 495070 942999 631133 589647 899098 219100 301867 367280 213260 824970 30…
Output: 74320

Example 2:

Input: 509 450100 429115 423027 130310 139815 23902 786901 759550 198219 753372 246664 103675 542680 184281 543856 658957 220716 96716 478681 615411 688100 953960 622322 959136 241923 996373 559275 94117 305857 256166 620468 979953 909587 912332 669509 951888 51230 102993 392606 279512 672715 383932 966357 69354 995187 618593 139770 761945 131222 455770 508301 334245 207192 160080 118484 777980 200623 950631 647517 240265 916219 802119 490043 415754 883975 98881 662603 267903 43360 801502 846101 964689 567775 57522 237615 398450 726878 66289 98412 370266 248199 566651 50250 951842 168130 299997 409125 99606 561884 95514 794062 199941 115273 512586 467932 407651 939364 782584 913232 178528 282185 598609 108146 822732 486617 141897 852164 442143 933943 973281 858985 788245 810403 602626 974054 5345…
Output: 41286

Example 3:

Input: 418 435513 129780 702993 547919 880894 23799 701222 382454 813948 640054 355758 129974 862645 441801 419067 131271 981450 142337 466010 827732 755546 945401 748509 945191 778287 696287 753431 311917 883229 163896 41534 982054 655563 443316 932408 384798 658988 744242 551003 160820 851722 106750 908074 273918 689561 330722 741360 305425 145897 477777 140836 946168 404445 343542 24569 424253 959666 546433 376107 206380 15473 473792 194128 882119 915323 74743 135267 285181 550246 870079 959335 595680 384579 190360 6861 691297 747140 258021 287896 330888 607476 5557 991462 45698 78980 59896 648160 425002 444673 912156 19937 253922 397823 970493 914654 731361 333647 337548 672249 355765 179121 656290 962569 557489 335750 559303 160434 488842 209306 889347 147634 623690 892060 189876 364010 6194…
Output: -1

Constraints:

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

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