CT29172

Quartermaster's registers Longest Chain

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the opal reefs of Shimmerdeep; Quartermaster weighs the day's registers manifests and starts the calculations. Task: Print the length of the longest run of consecutive integers present in the array (e.g. 4,5,6 counts as 3). Input format: First line: n. Second line: n integers. Output format: Print the longest consecutive run length. Constraints: 1 <= n <= 5956; 0 <= a[i],x <= 1000000.

Example 1:

Input: 4659 613695 141772 124988 850361 83521 28345 544112 981225 136785 725416 647439 800707 38968 442621 754246 697179 776350 400889 330197 909762 500236 321776 90040 188882 100125 68666 485932 144024 424633 177752 979643 658494 24320 989357 220047 335195 169129 315023 748847 571417 187424 945863 60783 669900 490983 961333 758291 181140 183992 417737 818437 554274 209165 135815 334199 296081 847550 430027 707124 835167 441754 37294 190473 104069 937807 843298 18339 783408 180693 227957 17296 230706 267991 450704 957226 250631 828819 7871 557885 721000 550072 88586 883330 276474 638636 633263 105086 696512 551177 891148 409184 167352 265062 93951 774138 672351 455664 490355 169976 406863 552452 675016 865755 318860 622013 538778 114239 31781 177859 418246 144012 44031 157152 918321 253123 313005…
Output: 2

Example 2:

Input: 1149 141816 595353 563146 162478 650197 566561 382219 832731 770100 532202 704265 45352 369629 823633 504390 626800 99522 963517 241613 568460 822142 51730 943721 342897 21305 293705 92874 270208 925880 911695 354338 259035 32413 172338 142387 374001 533888 448412 853946 437863 231281 128899 470046 968613 818445 370441 287116 196595 697644 558637 393243 274387 614298 142396 22179 104376 17976 383541 751079 717503 122155 127273 124485 856239 202554 326915 973171 939023 326515 20432 708352 351332 277890 276198 990121 884846 564251 21737 441966 254588 207431 544312 723294 336402 134155 50817 835542 754146 89758 7252 766109 217168 454442 763806 987380 465518 659542 510000 381307 45400 684652 660708 369181 739297 639889 116183 338352 723946 320584 296825 939094 507314 134217 291060 482328 70732…
Output: 2

Example 3:

Input: 1769 382458 674795 500818 342123 375185 360012 509087 907949 924795 692024 512104 764821 229874 779228 262360 919585 868350 910159 727541 230204 497439 990376 585470 915169 62386 770267 829978 238831 603926 127831 164786 775391 377504 829684 570943 3651 765951 320529 461314 275619 249721 298710 696079 633278 315257 40062 566086 580349 898789 639320 71921 341568 777495 810987 99261 1485 949668 624988 712297 235426 630492 168741 535926 744802 625232 21691 614511 958598 754046 671804 389304 895792 247656 682040 149126 875491 173058 587049 689745 855486 38918 31398 671342 513953 438632 772854 335815 448320 521633 7456 254786 105133 814502 730790 200820 564004 794524 784782 831876 905490 842638 398742 600955 194296 430290 989978 184068 56638 498269 898350 834098 741845 833000 590489 125410 5510…
Output: 2

Constraints:

1 <= n <= 5956; 0 <= a[i],x <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Quartermaster's registers Longest Chain - MEDIUM Coding Problem | CodeTikki