CT30808

The Checker Stretch of the Umber panels

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Lakshya found an old ledger of panels in the archive attic at the cedar groves of Balmcrest. The margin notes pose a precise question. 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 <= 3887; 1 <= a[i] <= 1000000000.

Example 1:

Input: 1581 622184454 489160328 221220006 894705577 947061324 811337800 888202674 934299213 589661118 970757005 501524403 890456880 140225417 593027836 187910340 634198968 341777498 183319585 196454500 236291787 145332426 628096022 750731925 300504724 703394104 648900546 87580152 748697745 828593486 600215540 513693287 26987825 150182843 432547589 424319984 59713474 748344430 697283777 825972471 610710372 697990391 423742285 654966548 928999959 56208722 172908694 73814280 850337986 996442967 707157573 481116288 472701003 731278030 211423910 660338961 214556553 159658652 826778144 922334259 745255656 715874592 82149107 208481853 53643407 67380669 984648248 354280577 428078194 205339273 681887957 322000006 74375078 211916790 261747006 265043077 863520265 621289896 893196444 974348447 640104418 9727…
Output: 10

Example 2:

Input: 1872 955237284 165524088 804824655 565684165 749218392 276101433 120082701 171111672 9029979 967122695 591358718 558514794 629395963 452116017 525999533 839880577 975063512 880333296 290442141 877890221 998743574 941283441 172822599 305358501 106106173 472357845 894256784 901686604 64416664 75152655 161811110 364991433 325413789 271849294 485696368 437672362 210311000 111197219 585907446 140155064 293428371 880925081 165465566 831862727 499460448 529362022 814751509 179551127 918929936 365094547 199540537 564478928 51810772 374644453 72693289 479196264 968814493 168922031 731506756 840707501 537540937 486152074 530686303 91473769 650746801 941405340 558962635 835383851 738103568 123398195 151850310 219688120 311218690 885651486 150974412 510346599 179626199 636686724 209016683 678115213 96…
Output: 15

Example 3:

Input: 3851 586625557 653520437 616512958 978031873 832487759 821342542 581870815 4277733 680922146 808397281 974217531 634702422 402633768 587070602 94656215 742590244 126208004 243728197 977057678 989532095 809007210 468418183 773577568 817751342 254527737 30761022 374927279 438806123 265323055 973750014 683776973 841432521 735174574 583393784 906319178 226567059 814160419 101206231 291046881 65563350 140819848 412488858 963873637 15227155 83746018 414843796 451502013 683603957 918566084 406302107 954487018 222387742 433900856 246965491 742265654 616008276 982142072 998063768 555631741 194590000 538685324 803424993 434869368 466101258 253181144 819229499 472774467 953207897 639877808 566811281 51115500 673988231 926093918 246273849 902627055 631239879 732686832 294049524 998122032 164049743 111…
Output: 11

Constraints:

1 <= n <= 3887; 1 <= a[i] <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
The Checker Stretch of the Umber panels - MEDIUM Coding Problem | CodeTikki