CT31422

Parth's Honeyed Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the bamboo terraces of Verdantstep, Parth 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 <= 3385; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1974 244829959 381815741 212291942 678640489 832326057 891594331 26220133 926077737 458509930 662808417 203604657 604519121 378808351 519302016 144137881 587516670 221183028 308832207 66400099 422906464 42972635 603033012 161379822 4691293 250205630 493494007 865768850 7397006 451761563 691213200 716813639 175281458 133921352 349268091 634934643 667727856 587263589 832605137 810512765 583537244 283367683 993062419 32967443 870426477 890988264 67042889 124136527 738671170 384775273 521376635 800363350 425337776 279720348 290537327 465989718 341000489 85996869 566152195 843680134 280741102 774010908 292707328 723211383 535749701 553722829 544487168 205778457 772540066 174103676 238064497 1288492 955871447 612756126 701492772 312204927 956748925 880705487 770027893 933667278 469076723 3820264…
Output: 9

Example 2:

Input: 1951 858089177 12288637 326144827 908993159 549319527 732637358 979844227 250481317 297140700 602838073 929553542 259322043 300471013 707989097 52851130 146168973 968119687 793369326 994246230 468009509 267637728 114102236 996202599 81390707 860965643 179697968 402755083 559698058 379992710 690115474 669373449 146008770 640567956 241764475 858656472 491302552 967263992 623386932 223678439 94880444 175182680 884128686 258059801 636676656 11403054 580408459 622576236 351666448 459369808 907575471 237778653 353105571 234311111 34328845 682845572 911756211 365249716 73738313 382990057 810162846 137380556 447626940 368881538 418142557 481479457 958242113 606084547 295847045 826630289 475668595 407667275 643599398 679268181 764220646 737988603 435982568 780525446 704703567 100433609 341402663 85…
Output: 9

Example 3:

Input: 1461 504774406 140613183 530946366 120353738 41503947 817535441 49396270 630610833 791514750 230771647 637601185 598564079 454685453 274456842 362451608 402090608 115959401 55571226 913740965 798940333 351356912 792218737 773850891 796817137 411593140 426516611 764354126 744681024 893832532 794592940 875307291 225476091 890988185 330139293 87734801 774222549 416799390 270132788 151332930 32555846 118558396 872531315 361044425 147706319 54557147 358204591 82412497 509984115 69225107 248807960 204235810 68293484 866352917 799398750 294740021 599338987 302400882 847262548 162920270 302188016 590429102 545251143 701458885 158465284 673205902 898236580 508457028 846788310 366466911 359441041 14273882 888867297 679340952 829969947 547218124 603242653 486550181 270697223 465393229 117089055 14110…
Output: 10

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Parth's Honeyed Ledger - MEDIUM Coding Problem | CodeTikki