CT34716

The Zigzag segments of Zara

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the honeycomb cliffs of Beeswick as Zara unrolls the day's manifest of segments. The tally will decide the next shipment. 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 <= 2332; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 666 235233 63224 -974610 939461 -267818 -219968 190944 -609783 259292 640621 -849782 -690733 -505456 437988 -617876 -956201 894400 -989034 393052 925566 749109 -346770 -471020 427989 907910 -174366 -878373 144244 916660 372588 608861 -686655 -105600 -22950 764896 808099 -236583 -805630 -185602 918995 -362581 470503 -409214 332675 -518175 -612790 275690 -365737 283413 -430143 216686 -446631 76220 129026 -314675 131088 -823591 -394167 -929134 733557 995732 -222041 300391 -537263 251410 792856 210985 -628279 -909483 914074 -88579 842003 748552 207493 900399 -416309 -546221 -356002 -351432 -942949 -378386 -316639 -234991 480097 -459254 38995 -607068 -325329 -468682 484972 577601 -459933 -495477 179620 -414234 649014 169358 648600 667942 363493 -928924 491476 36001 172539 -139604 -228354 -46998…
Output: 8

Example 2:

Input: 603 837265 345203 -77102 741384 -265108 932022 993379 356064 812531 -591792 -559019 -643312 -172511 112917 276049 -336617 -814871 377962 -189480 -608498 -989290 -805581 -702363 -325112 434823 489569 892804 142956 311620 332970 762596 -995721 -543590 -984064 -109875 -915918 -707715 -512756 752035 625323 -852318 623051 336142 -132414 -574330 686143 520446 -172189 -449109 781701 -957421 783614 696153 888487 -274741 629355 564752 -790758 -969084 147719 236545 107026 70913 -505512 757417 984514 402649 -778065 -305848 313622 471671 -492757 -76691 361448 -80994 606908 -302887 339978 210894 448609 -656974 665145 716747 -9789 233701 581052 -974063 -325610 -232204 -306093 -280520 648397 -677642 927468 -126119 464946 546542 -259984 -415570 -495387 447746 -407420 -307200 175776 -817347 333191 -964961 …
Output: 8

Example 3:

Input: 905 -625624 -658223 543875 553579 -150774 -271448 613174 718661 -176879 275353 -991695 -654705 195247 517417 971196 -863633 -609110 -790970 107099 -77428 324016 -350282 -281084 145501 -296185 -6638 153028 944992 -418008 389515 902004 -593552 231341 -69151 -341245 -674974 368152 -192806 361644 376764 -142702 -810492 -899178 -573268 777188 -467031 -519024 460954 615510 -877715 822315 -851976 -845715 -436401 651752 382841 206668 196343 744248 -348772 97097 -756571 -667707 670824 -323642 -408343 -835674 -393768 -651273 -42412 -755291 -208535 -75369 -640560 -123346 -190149 453262 960229 257521 -317692 -843123 -998961 899879 27961 378585 215927 -639878 611221 -186273 250181 733761 -457013 179027 -668795 -952901 -832121 -811162 642739 -716137 458728 -860858 328846 -139883 966389 -863037 -397035 8…
Output: 8

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Zigzag segments of Zara - MEDIUM Coding Problem | CodeTikki