CT33716

Felix Counts the scrolls

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The reckoner Felix has been asked to forecast next month's demand. On the desk lies a long table of scrolls 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 <= 1229; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 1108 600247 -604145 828247 -512382 -272397 -839295 280438 58806 -984502 -434046 -304484 -122908 -178522 583658 -816174 302386 539804 -900056 -273595 773052 -645638 900132 612594 310842 697114 37752 767172 795266 -459611 677875 995848 246350 879110 243362 216316 780385 -401363 381909 891577 -106402 776584 666329 421878 451906 -152504 738697 -553272 897987 204779 -958436 856046 320022 828759 -650847 82290 -223074 305715 -364054 294063 588460 815778 314216 321982 -765274 -696383 -524334 -974752 909844 580308 838576 -266248 -651610 -827789 -874986 749928 -833647 -51797 -674753 -308716 586079 -727684 952070 -889872 227180 -878538 -76020 681472 104399 -910094 -114140 -2748 315360 765292 194582 -124197 452816 -376067 -594740 58708 591361 687419 -343625 -620607 -158187 399869 827867 178899 -853770…
Output: 10

Example 2:

Input: 688 -858479 -428776 -349174 -133548 -914580 -295491 525412 195443 -765297 875512 -530084 -16835 609537 432731 995944 768004 -716798 -680550 946619 -614515 -109102 -743272 -842558 63294 -504974 316815 -825022 -816001 -11451 -999327 439185 99472 -271143 108425 457701 -165977 318475 -593461 914652 -350052 -411700 -953884 401436 -848494 38276 -204631 133913 321942 608347 -31011 23749 862746 734112 -816185 -803758 878085 70726 257183 -640425 -53098 30780 776739 120509 -576141 317846 -25435 482919 -200571 -903524 684603 -858204 413711 -729545 796492 -497414 -721033 -135258 1522 -668493 484571 185259 -622868 -445094 -917293 -227211 680298 -309787 222078 -572154 909257 -273224 482050 303940 366786 -857346 194397 200028 422845 -874687 -853019 -524695 -807359 -170210 752917 -48609 -476751 818013 201…
Output: 11

Example 3:

Input: 1127 844195 -248563 839433 380036 285989 -162872 -552895 996823 -175283 -535126 -39406 178126 932533 -417763 873142 460766 -658852 -41466 -236669 526128 321282 -698402 -309220 799708 287233 381635 77429 -482184 362553 314185 981949 -373380 357626 -661114 -337628 -16044 309117 741015 74831 -206928 -113300 -157 -658231 757869 -386379 -560833 -162970 341967 -911231 180578 710883 -54008 800999 -33574 -997389 426756 460091 -841123 869565 278480 135564 292307 -604676 -714553 -370632 -751875 -465281 170777 -417925 -594130 697192 -291713 529272 -506579 -53011 -136392 -94272 -778119 13206 218089 470248 282789 -566482 -488970 -736839 -16296 -382934 -160324 8036 579853 268006 870812 -520342 -885449 840644 786280 284535 690873 882560 733803 722955 545886 -393599 787631 -811713 -981714 167780 370076 -1…
Output: 10

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Felix Counts the scrolls - MEDIUM Coding Problem | CodeTikki