CT33404

The Solar Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the willow walks of Reedmarsh, Chandler records each panels in a worn leather ledger. The guild wants answers, not guesses. 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 <= 3729; 0 <= a[i] <= 1000000.

Example 1:

Input: 3413 535407 408045 808604 62508 515613 862734 922228 12533 493148 919457 320848 279186 308521 486813 657155 782078 799369 556360 392570 549174 351266 313895 840295 571767 301595 14560 488692 208248 178586 645963 697170 499805 491982 639318 855039 224768 693491 657241 329961 24987 46802 756686 617350 987975 876862 622011 11679 107386 692963 519909 294871 931060 379931 137336 734314 141365 317136 305891 13533 877843 795373 982882 529493 831551 463136 79463 649114 620085 269130 773148 355121 205464 545656 923293 296371 169021 412278 476860 58647 797245 63867 948936 639851 472796 338837 30200 817284 838706 889805 319693 132408 439503 902500 78429 855556 484770 856890 673092 641378 632910 377087 613085 504339 785629 977546 645680 311802 234514 986540 770793 773421 976563 633508 6400 356352 8798…
Output: 11

Example 2:

Input: 308 778157 376124 539863 296036 696697 906778 714701 253562 578264 48741 780098 626936 190966 993781 176850 3038 583563 806894 512854 39071 530828 987469 205405 563823 649096 140168 139892 56732 979821 630175 344332 274050 457427 227034 400622 565021 287790 262570 89810 761554 51206 671369 544756 34514 249512 902636 518420 388614 954649 791223 195765 987219 112627 34909 207763 541902 927851 721176 56554 68088 309578 520047 387156 140315 990111 83552 184502 862832 77897 567043 556342 814324 358687 407718 315166 855923 773188 614866 281465 707396 553719 78284 449499 324658 242148 993122 368106 43536 220421 364673 312298 814449 638668 752724 110732 697904 198501 844190 66013 241727 967488 788184 303656 917789 34668 841943 421552 48301 402939 657508 378845 624771 178666 864111 979953 620866 49…
Output: 9

Example 3:

Input: 805 29235 136153 331091 183925 769046 198025 730464 915808 10281 278271 28164 731297 818729 732568 490188 661765 101967 815998 726916 758302 86128 40022 718868 876375 720504 910913 210634 204719 262559 152670 332538 924301 63142 72840 637371 284509 961328 358526 130225 708802 367920 91649 172699 849385 751031 393522 829925 259407 163458 349504 205486 511825 666518 597492 170444 478218 765560 987374 392473 33761 381608 115686 641864 116936 494891 221930 574518 221160 396246 457797 11080 282536 943041 25920 738330 842942 153727 399162 980520 287055 522486 808646 113650 817979 641524 793106 376136 883707 573228 446866 786 216372 741440 246090 257994 409434 415723 417163 342183 710790 423712 977737 665438 511891 776712 870737 272731 835579 187242 377749 379517 434662 935877 369708 145076 90036…
Output: 10

Constraints:

1 <= n <= 3729; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
The Solar Checker Stretch - MEDIUM Coding Problem | CodeTikki