CT32884

Last ribbons of Ishaan

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The harbor bell rings at the seal rocks of Barking Cove; Ishaan weighs the day's ribbons manifests and starts the calculations. 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 <= 2435; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 44 952296639 407998023 103709663 747759416 943454192 199955018 460165531 78669529 346517938 474342463 715834403 173113042 561334842 213644234 566960963 838475758 164325189 361240878 743598245 637828283 -490462 466011010 280378986 149204719 36281589 31578886 184269737 469935857 406686855 537992437 639229344 227002996 403016756 468357651 292990628 73084135 254712602 743879422 79391302 955168882 139412790 276954933 268733607 255530461
Output: 6

Example 2:

Input: 1063 421355640 992266305 764292600 928885766 826108359 683519392 757826946 816884277 276539688 714302272 173345403 715526342 212159312 768437918 92082875 775702524 18265369 199250073 754082216 907264818 701401488 955577829 946192934 86536333 738692240 696441871 848267887 368954201 895051756 566686227 652379091 580779002 983012739 561949285 601074889 194213013 73685174 586901924 906853595 21272944 177350922 731992635 226659186 942751131 356011578 188499578 959254266 228218894 576609970 42145588 357704279 463722551 504369650 886435336 757363439 751730926 738711428 814305016 550841422 23996614 56978446 396635755 248412138 833615636 708868496 968744209 289287403 661631170 257580646 192857829 155751129 600914280 135184087 606121912 572390396 415738825 910348395 347285164 474009278 232469551 270…
Output: 8

Example 3:

Input: 1485 182832204 396485556 916585416 362303442 330129941 557199474 13257989 826278040 994471146 657651422 475602258 138956728 48975042 77507410 475899138 471695033 42294384 759508039 725747682 212106219 568480923 397058498 521279427 565038785 402302328 585716639 324938660 203946727 37607623 536633903 637691566 230115329 39876351 43783948 410375828 439773878 869290228 708865582 509304467 829190157 93997377 41521392 48057755 248860762 87016328 289071683 887081153 600023816 700522790 703673683 795656831 902641499 627536524 36655191 743622519 531367976 667091636 189962691 855124771 690427454 841892471 97331113 215336871 835290155 656359624 688402457 537521070 399115317 290888450 586525791 497300223 654039453 354682438 303306598 953780023 89000056 543935511 404639690 898559872 388150027 792672031…
Output: 14

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last ribbons of Ishaan - MEDIUM Coding Problem | CodeTikki