CT30740

The Checker Stretch Beneath Shimmerdeep

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Kael inherited the cellar at the opal reefs of Shimmerdeep along with its curious bookkeeping system for segments. 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 <= 2968; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 648 311735215 475384558 474688333 205488653 58671569 940588688 987932570 468446181 514299337 380341974 895390952 329011163 770983501 600716693 491948152 882061193 952779273 322141918 244016826 388261195 646534518 305294143 829031873 612554847 101083749 769647815 474265634 543901295 23060856 887805722 615415011 639206588 824695020 904981358 898371095 988918722 80365397 349369350 687199437 134728621 411849774 171756095 141033190 362908303 950269169 665126946 590391036 501497135 470150625 796424075 55236854 704052327 259563798 604919074 320708027 743566891 8662955 160812900 660448726 251475327 776960821 393534969 659398735 96289008 632513724 686097007 966210056 35965757 355234735 310554871 5270467 267474653 612210595 322943520 277669658 408046200 124460501 514418235 903429522 775350467 590138…
Output: 10

Example 2:

Input: 2802 404614113 599275863 860148039 935956650 932702054 760414925 940414781 383928874 134924065 156249473 757585915 676197995 906333540 922976459 305385500 180818005 177362013 245932260 902547090 257084931 112464594 601489051 197434761 334466257 238690185 57221551 822725751 498164021 360500462 347671384 291281042 308722137 825652105 625081691 690947161 625050662 918054334 765484630 998758332 774254932 416769298 800229828 105388214 807519585 229031893 768516338 622559984 666119099 571617039 666469884 635318568 360771502 775877847 937143121 260980460 393149773 273052108 399285914 568599196 165243776 253565752 172684858 315638625 927766441 792806652 196369705 217749609 790436507 306833937 616791673 966953503 331228044 568871995 347068814 553241010 717602489 600318306 299337114 603583630 213224…
Output: 13

Example 3:

Input: 423 495647794 802228263 406771792 293746026 847186264 995417675 660368077 877594265 204858069 21146744 358123653 256362464 418512482 836655007 285129102 734055488 343840109 827146382 148921752 21636725 786885037 794267407 495247101 481390385 888591732 863147118 945306407 380666531 72847943 412019225 996995714 173905064 501662547 55458741 999776978 295084064 739409884 133024220 679115861 49532201 165964824 594322222 521941852 950753520 183370644 586136996 710381723 690837344 519423258 983010958 792838525 866130616 751554956 38632284 741251269 59873098 781644554 639238079 585695092 407274883 952050196 14662596 911322009 161677246 100486909 722226635 160147765 593533933 886890132 663068715 429062342 745746830 370882804 615043636 341709978 288775912 17895798 675964094 829341044 410291603 14562…
Output: 7

Constraints:

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

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