CT33600

Cleo's Longest Chain Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the seal rocks of Barking Cove opens only for a perfect tally of crates. Cleo means to find out. 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 <= 7346; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 6428 -526877 -938801 -106030 -638503 -137021 -947982 461807 -718461 4843 714750 -341711 390059 751161 108419 -63307 682086 700221 -737670 968451 507923 -738877 668620 328389 686284 224488 317837 -9677 683190 988040 -892000 -180838 18482 453332 -328696 -374277 -560888 138197 -54236 815437 968588 550062 514982 -891694 -175356 -841850 151511 -313098 -807594 258947 653031 258923 292635 167004 -819442 -969715 -754260 854726 311761 923020 -742939 380118 840718 264211 597246 -774237 -248723 103591 -310463 605770 -138583 -954533 -700888 -117471 572170 726938 435407 554258 92396 -274175 799776 972317 -322721 -428553 562270 -705225 676081 235780 23136 243246 -173294 -522275 -242802 -340687 231420 428624 862967 502765 70801 -392072 811028 480324 -617054 216033 -590162 236451 -670873 731392 -632953 13…
Output: 2

Example 2:

Input: 4015 -761438 -641039 297569 424225 -711337 302008 -198171 -128448 -442871 -639364 -707598 614201 774710 -115136 305917 -655826 975732 -126775 260776 334498 -511466 -28910 -678218 -719443 -627329 -133064 495515 -252697 -556756 -293591 -196724 617791 -563309 -117598 329159 -266438 -512531 302163 -650136 -186757 -450827 542066 -510996 -84055 -880288 -188663 -924740 -749262 790860 -719045 14571 231402 254043 164497 703002 849286 943733 -697635 89930 -873662 -725239 -375649 -774886 487147 -190964 -223971 -834517 767040 -295492 306250 -582742 260076 -229822 -53729 189327 72221 -498076 959297 348546 -486395 730753 989564 629631 739364 -739688 -583941 -74124 399484 719645 122654 -767739 -392376 820766 -848307 -498886 411490 362438 775125 -794665 -718288 -491794 270601 -502009 576973 801909 25399 -…
Output: 2

Example 3:

Input: 322 -171394 -171387 -226486 -144918 -248631 114166 -377535 -133560 -857975 -651441 -152020 -648886 844857 -229432 -438806 800183 -637965 14953 -609580 -966570 500242 -445329 -904564 481943 -794124 878973 -526157 -94965 -667948 909039 -453908 -215276 -823069 -993358 870760 -986191 985819 831426 569575 367136 -738245 358887 97504 364639 -243798 -584817 -755158 -127739 -546912 81614 235903 194174 -856859 747781 206299 849382 615916 877830 -629168 940648 613594 858260 -682614 -838957 -170482 -974666 -240618 999631 -365091 939774 618337 -321872 77769 -913728 650902 -527462 -614038 -708927 -549703 334652 148576 863581 -305997 -666389 130317 266906 -4998 135184 691018 -269239 -921674 -960220 -694653 -824959 756974 -265199 -717438 383613 -455809 -905674 298283 828620 203127 -385250 782915 -46667 -…
Output: 1

Constraints:

1 <= n <= 7346; -1000000 <= a[i],x <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.