CT34223

Opal and the Zigzag panels

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the lantern lake of Firefly Mere, Opal 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 <= 2773; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 121 176927463 204002245 765079953 534581179 926439201 632243841 779285573 842314370 571438806 725604160 20160800 288219811 808221468 202665207 571311795 121692519 736484947 493542949 617069727 942392123 82370059 518234373 171403435 123722593 560236524 570897785 780229332 110251858 12366780 418905112 9915467 581909716 870311913 408120112 335193109 -940610 95235159 530881143 126315342 310150284 149129811 429320190 949249620 994243369 799531981 110722036 199851900 455923678 606341829 991912847 280676278 793749402 810126241 607735288 367694126 747508899 72021566 815457928 274369574 331669933 477450384 937944498 731830676 261082674 67285382 701697153 964516959 919171300 536476069 581766000 751451196 804629370 900083742 503855450 18664280 43872161 860870039 864321319 735745604 545952686 14288268…
Output: 8

Example 2:

Input: 2513 372894832 331425747 352901616 814861678 344145163 468867802 809693333 40296060 203084199 301331897 19881336 828228994 439079988 331164906 828702956 562520854 164905892 804115380 56697599 96528254 601926979 759982220 15836556 505039648 359489140 342254602 12996442 411879883 969927771 43917155 590021199 686614025 769327965 611359602 283388847 541891032 927033861 773867145 145072775 721191790 207283845 362897286 487644458 995120669 235250738 806061056 981716165 614645526 725560234 76936731 410142452 197071279 373813565 723374139 119692138 147289681 128260071 857581290 195112022 388382329 925066446 244210418 217081024 952861595 332441327 480740648 352567960 461088641 945165932 436282752 902065202 445002906 915953347 730256108 978794889 603582716 210745877 902406619 790136524 986241499 713…
Output: 16

Example 3:

Input: 978 491753479 802787037 523417165 334274136 338423343 403154098 436826261 207676186 935487500 227649514 940114381 291515400 809084268 460848751 428324445 699476437 122221253 969900863 699647678 333878547 329501711 332941767 220594131 93431775 552245463 670271083 53234810 69464778 790143661 55068347 313227886 358104836 964407937 757495664 49363955 362601871 715672298 560467361 935253371 1443020 978782596 83898510 853653360 916809963 757740525 140648861 875700349 871373092 79341713 604449474 211101541 108446939 794878395 216980446 665810990 126803440 729884247 32396492 731677738 599678531 895037041 535656437 432232783 11096624 851246860 602276627 616773028 28661103 551011471 720231833 604884640 953001835 387033938 493800715 67283244 217737080 949243771 908548041 499224603 553825963 87746421 …
Output: 10

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Opal and the Zigzag panels - MEDIUM Coding Problem | CodeTikki