CT31152

Chaplain's Ledger of weights

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the cinnabar mines of Vermilion with crates of weights, and Chaplain the auditor must account for every last one. 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 <= 5154; -1000000 <= a[i],x <= 1000.

Example 1:

Input: 734 -766365 -730266 -237479 -51533 -50653 -528730 -381361 -607072 -297854 -137356 -350910 -590999 -115905 -941116 -437113 -411133 -694103 -216977 -433502 -674462 -397258 -669359 -572746 -299624 -988411 -747189 -625417 -122138 -483511 -212213 -241903 -575250 -859256 -82898 -382312 -735736 -837363 -224193 -530333 -874649 -640701 -2786 -816276 -468442 -992822 -981546 -55580 -174650 -621346 -116560 -419277 -763180 -534279 -375961 -7427 -921664 -218994 -438581 -745614 -780210 -578203 -702594 -271264 -297254 -138541 -670251 -424042 -278552 -431366 -821990 -315668 -636221 -13042 -231046 -540896 -394279 -410328 -576191 -380955 -456716 -97477 -268558 -101204 -52257 -55714 -577568 -81744 -764472 -547757 -613585 -972157 -503866 -412529 -360034 -205880 -659227 -475577 -986008 -469438 -556182 -497144 -…
Output: 1

Example 2:

Input: 3230 -391035 -431300 -895980 -81930 -277729 -350415 -207867 -602148 -465071 -35339 -796412 -952439 -230605 -158957 -130737 -52931 -70174 -956590 -332851 -329878 -107738 -355341 -256667 -157556 -176953 -868540 -906487 -259844 -173401 -169556 -955189 -131311 -55241 -524513 -550753 -118083 -109372 -354053 -931929 -140452 -799726 -525623 -553696 -558355 -196117 -907939 -703780 -191926 -690698 -455308 -519694 -586131 -172374 -902826 -700931 -652196 -445114 -968119 -345573 -314338 -968718 -687650 -965151 -350415 -537987 -321409 -737704 -602896 -568079 -372066 -638362 -863707 -156766 -205052 -732579 -678555 -175093 -482493 -373995 -120476 -101330 -294763 -349252 -290727 -633500 -329553 -977384 -496659 -282574 -93158 -154044 -622770 -231824 -329113 -899092 -238948 -149576 -514059 -93064 -5554 -352…
Output: 2

Example 3:

Input: 2643 -205908 -837837 -408397 -20134 -958740 -105452 -355846 -275805 -801770 -434217 -350196 -675547 -620731 -807303 -464192 -323251 -540821 -371541 -984964 -377596 -914714 -600383 -774559 -885361 -305521 -370399 -855719 -527673 -531452 -38472 -939555 -904957 -779007 -163657 -182847 -936836 -217827 -83043 -590885 -531487 -420587 -534736 -274357 -673615 -453810 -431686 -64058 -664796 -984699 -436742 -804276 -647766 -537340 -976261 -614700 -828625 -800314 -800636 -274366 -269101 -561965 -894808 -793611 -964161 -979726 -892278 -165387 -217725 -287399 -92591 -925937 -297371 -576731 -308029 -844404 -190940 -795567 -669793 -309420 -538170 -757013 -532888 -225270 -118321 -85881 -776223 -98268 -781490 -537045 -481744 -662465 -528732 -414505 928 -406601 -705120 -836161 -245438 -591619 -328519 -76265…
Output: 2

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Chaplain's Ledger of weights - MEDIUM Coding Problem | CodeTikki