CT31019

Harish's Checker Stretch Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Harish inherited the gallery at the pearl fisheries of Nacre Bay along with its curious bookkeeping system for scrolls. Time to make sense of it. Task: Print the length of the longest contiguous run in which elements alternate even, odd, even, odd, ... Input format: First line: n. Second line: n integers. Output format: Print the maximum parity-alternating run length. Constraints: 1 <= n <= 3052; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 2509 -867684 994751 -40312 321990 223154 -122176 -401897 -478070 118239 -92162 425617 998293 469153 -614307 -95695 -926254 -770391 252853 153289 446591 32985 -257567 -844994 -693907 -109161 131020 -756561 186446 -722819 -853156 359409 -781347 8819 -402220 -765274 170598 838563 44008 236332 278271 -918146 202520 58757 772385 -976165 -645197 -768616 530985 -510566 -878631 740725 -172048 14881 508963 -101840 -557711 -335316 534450 853410 -870310 109910 -548259 375468 952656 -724571 -671790 -276922 401268 338159 -286457 616690 -676039 824310 130337 -541234 136066 -943273 166761 814509 997061 532211 487937 865297 -898106 -83998 -621590 -245120 535780 -313714 -59362 -741480 981361 -698161 199433 888043 -285506 -886589 380618 -449872 453278 219138 928166 366806 374261 767928 -445413 -122747 -4160…
Output: 10

Example 2:

Input: 2368 527478 4561 180423 541704 -507338 652383 209217 -197569 -190076 -565243 -467976 -54405 -736277 37838 881255 -896975 -806342 150387 428375 373030 131938 706694 -669571 283567 -731720 -379543 -956575 -284037 -198774 398863 112551 -393190 -742539 -393962 506987 514048 -985293 -194302 -274508 -11261 -500457 534868 381592 494179 709025 318695 35244 33704 633881 724249 -598302 97835 -143725 163551 -536005 218676 -204917 501607 -285314 420986 -482835 -28976 -163646 283681 594225 402914 730714 -536848 34082 751721 -56457 -31659 75864 -873799 172113 -713622 -905906 -226013 -762577 183997 252443 -214773 -160946 920470 31438 -43012 -698890 -976794 582849 -720915 -254381 788772 346673 950893 -966541 -749886 -483033 -393622 -348187 -620272 -653730 -113333 -785557 184821 -459401 -645306 478650 -500…
Output: 12

Example 3:

Input: 637 -461508 683641 -974920 -184549 -186439 -50563 -575662 790612 -146796 -134671 328831 103889 179353 -208316 -348304 581652 89046 -604079 -59727 229483 556170 998268 -271108 -830936 -952227 -512659 -194486 -960456 379328 -113358 -806382 -70727 -305146 -421011 470785 -277623 -712390 -871950 -724999 989009 -167747 -488031 252340 -454749 -551067 721551 -962436 273138 -902543 -137738 113095 352646 406241 259102 -397841 -2780 427718 -658897 -548074 -662589 996279 513671 -941733 941224 514472 253923 -308485 508785 -43299 -794930 -603392 -781398 847656 -501975 -879285 831195 685817 -322725 671610 -205214 877251 -254690 913502 164864 -925179 -551017 -235635 -728514 -485064 682612 280129 619346 360719 756174 608291 712473 20326 -415856 -506489 -693141 -985399 -458928 -93363 417799 -677873 631232 -…
Output: 13

Constraints:

1 <= n <= 3052; -1000000 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Harish's Checker Stretch Ledger - MEDIUM Coding Problem | CodeTikki