CT32107

Zane and the Tempest ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Zane inherited the dairy at the pearl fisheries of Nacre Bay along with its curious bookkeeping system for ribbons. 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 <= 1000; 1 <= a[i] <= 1000000000.

Example 1:

Input: 711 691533035 256433045 188035041 80609686 423072347 168770215 102499608 107029440 567242471 767971457 309896571 769270734 42197686 91541394 601304293 453260469 496023266 555700766 983041274 296999684 784387502 247273438 343898146 927697606 68153322 992095357 359335969 74318093 329732422 170383290 85708394 658912941 316642896 375646849 961462869 353490101 94695081 872101335 116620619 356230742 706040962 2260871 545395514 977492004 785404573 992017063 690675758 709553619 369004062 934012564 721525613 564500552 967644245 268336046 31346042 191471283 271383162 100928584 220598929 940190813 26146397 134742632 343547474 861629708 343181249 991742617 996147580 838115530 624251542 315183366 971781578 422799194 596087577 842845827 609465768 871422404 619745949 608053197 151937699 807323603 7117980…
Output: 10

Example 2:

Input: 717 648168131 804950276 641359849 556431828 639582091 631229515 911062554 870635998 265669769 398762826 994683384 973868319 183539494 457316019 894294636 882387965 198261103 385874705 83438069 113006635 314932738 151581169 464903595 981414146 981816812 88057775 170776696 934315108 376704332 384531060 851570475 451997799 124871907 591719813 522726557 162315808 466310098 569029781 997882118 447380572 837996569 85653932 790314612 826930277 881566376 885880370 199990376 133772683 525042999 795255023 557748000 486326345 175124778 819390008 75158836 656077580 281850343 720760194 208859818 619543589 60947258 1121144 688922018 872630926 632655352 601242653 229391908 590195981 730073322 28043008 172007809 710487173 276050371 178262095 572143646 358660180 277134194 759902688 552480129 55020033 81847…
Output: 9

Example 3:

Input: 524 282246638 604632568 548446371 532281077 56570862 826601497 363755101 743927139 198711977 970745546 607502388 877372383 837750365 126293759 441600986 169961969 792935849 701532164 213210637 671335980 549490320 877354326 201890764 558891419 757111937 273060652 487080446 554561008 494513710 428959259 937087442 373659417 879816683 150630593 182304726 474950550 431267009 329107523 388845460 365702229 830125695 7986920 425527216 12606619 140050905 767189310 699043772 551788756 925335447 169274821 769956 469429081 868464001 726245150 139278553 906537494 383455127 854998856 949365576 302690240 481550219 619321684 252458199 130208780 180464461 658693655 942382445 438793706 852092827 297021192 496589717 71977489 387239022 253256064 335620755 684216755 2981659 168730943 158471265 943119368 216581…
Output: 9

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Zane and the Tempest ribbons - MEDIUM Coding Problem | CodeTikki