CT30721

Boris's Longest Chain Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the beacon hill of Lantern Tor; Boris weighs the day's crates 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 <= 5478; -1000000 <= a[i],x <= 1000000.

Example 1:

Input: 238 81213 782986 -464159 -486531 -903503 -450380 61536 189169 377217 -457762 23777 10775 -478484 921961 -703950 890056 -211717 -511706 -817813 -953523 136828 267996 -880838 -355560 -903982 374539 -998234 611249 -705502 -303671 -913984 456489 230896 -51973 -914641 -497387 528763 -40330 376239 202661 -255234 -443248 -519541 -71238 486790 434868 263955 -686552 77924 972285 88293 365144 232613 409694 -21052 988572 -873173 -102284 505444 675594 -917508 871012 -202914 323271 -388778 -986246 -828361 -711700 -945192 841241 -165219 -368126 -960439 52300 -836049 69075 -458374 875969 -542071 -830930 -277979 120863 -176235 641127 760121 -657928 160732 145788 53125 14105 888943 -900944 -993909 -895844 92178 146158 431571 269815 -270547 -287251 -32151 -554567 -74117 663931 635189 -401509 241844 981720 7…
Output: 1

Example 2:

Input: 5405 558282 650379 -932341 438915 -110534 -469618 357591 -578021 293356 -24979 -455240 317023 -84971 419500 -460486 -571317 -479249 -34262 -157712 728436 -58836 696870 -649843 621912 773275 -491824 -222764 -704643 901810 141159 413368 447996 -709569 -995291 249152 -702425 -11859 -231936 -211615 -99488 -54281 -843026 587834 319324 -811059 414477 -937405 389829 -559696 990020 765063 867802 623673 -815326 839951 984971 82666 -159082 519319 -477519 799212 -201670 -23766 -106109 899482 124397 912903 -575216 612933 464399 -137692 -59776 235419 -994057 -385905 229113 370481 -314239 -53974 604694 -523794 740101 154555 -768640 -258477 -581661 269103 251623 -31076 369395 -796312 -762123 981237 165417 -273016 661451 229415 -757487 -429151 -717894 292289 204314 397451 575283 796440 230271 -854040 5381…
Output: 2

Example 3:

Input: 2750 705822 -108240 -579047 118065 981182 -952403 -11678 504011 748921 803443 -180771 555267 -600277 -968055 -167952 994426 604530 -721130 690565 -201153 -27163 906193 -195805 -328830 590 -285087 584976 430783 848681 446164 151515 467482 -472597 321523 -727086 111430 215304 -198876 -162113 -557496 -643682 -510536 236201 -84904 510020 294328 -16605 -555184 879232 -732825 561286 -584579 429531 -950063 479137 65553 -621555 -499517 604618 328377 -887973 -688932 262393 -414067 -164829 824778 943507 6511 -157652 -909816 -537563 525225 -385281 -716189 113841 -462461 -244664 -42150 195839 -497295 -503139 224571 810365 -299173 -765068 -405873 136885 107813 202235 -295568 836539 -143087 544647 512332 -619381 -9956 -591368 179253 -676821 -172085 -4824 438086 475054 548220 175351 662847 687105 670422 …
Output: 2

Constraints:

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

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