CT29837

The Checker Stretch Beneath Shimmerdeep

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The factor Ravi has been asked to assign crews to the morning shifts. On the desk lies a long table of ribbons readings. 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 <= 1917; 0 <= a[i] <= 1000000.

Example 1:

Input: 1195 972260 337267 316467 49094 749601 7715 671844 588706 608810 863607 872386 957387 147726 995769 687614 232438 332581 280051 748036 863463 921841 417352 686547 128281 204477 944188 379447 719330 731295 697844 204376 447471 280229 132932 99749 751117 634855 525525 412948 942894 67991 539223 245648 422935 933894 558026 584971 881304 958457 478339 981607 209693 94368 382655 707923 24188 933726 469010 404363 965925 574732 763427 916535 481800 599337 584917 393801 477766 265668 687880 300775 607054 838191 128207 604662 287498 820859 247263 74213 211044 657114 891602 628149 921238 576177 502656 565523 765350 733559 842086 938781 867296 565666 636540 763453 384671 249278 530656 448490 498102 683914 306348 509818 466081 597393 201082 22031 261508 936718 358761 407071 805934 350219 881246 335835…
Output: 11

Example 2:

Input: 641 880163 21148 883866 361233 122055 657165 466152 360916 893818 831047 746178 170228 413237 384683 264600 796119 237148 860354 949074 562091 469306 534825 45607 788551 479764 384470 88730 743994 510077 416246 678502 713490 731283 888591 268657 997104 600330 752237 276281 635199 222154 10269 995519 42140 371462 898638 603618 379414 92450 350709 128586 726910 201014 859669 748163 638964 390416 847738 84972 678003 791518 800089 532038 451526 779938 907644 94901 640902 839159 995654 63688 894181 503912 190478 300881 109668 724624 300892 723770 843790 275525 842911 179418 138809 725359 224671 30157 76790 837577 428334 400947 985878 40833 654967 993423 117715 521074 188360 246225 878887 608069 304482 117913 678496 611866 122453 211586 653730 709712 625790 911457 689820 269622 734450 392987 323…
Output: 9

Example 3:

Input: 355 22187 905871 268804 636655 309543 398853 818258 958590 75665 537166 635258 569908 668722 532310 157338 403221 521196 573636 142231 952212 889826 212317 44391 474502 390248 998630 662190 609434 705141 879656 912034 761798 158232 347953 911419 184099 893594 776524 109978 663578 310257 361865 65438 17284 28953 341526 193462 711560 917035 755499 586215 455886 958698 227034 483254 234291 822361 646075 737446 425526 486882 431798 74801 458805 758165 266008 956057 96339 210100 776965 882717 580896 956999 541761 993853 971109 254811 41272 958053 628762 461261 441513 335765 886204 643554 334408 398176 702084 636267 981885 2745 217300 944918 718037 298339 949730 288015 486992 967385 635102 121537 507306 642653 183368 243826 551360 125573 520671 976970 150740 317174 73389 826798 970410 357977 921…
Output: 10

Constraints:

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

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