CT33521

Roving scrolls Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

At the desert outpost of Sandspire, Tomas records each scrolls 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 <= 1898; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 119 273264218 587852502 827912508 774772925 897035794 907986800 580815753 465781690 34916202 370101176 568128271 769943468 489305005 475748430 911668449 709889486 140974380 987890327 102781593 803767378 546110966 363932131 972536649 313061609 830746610 944037880 799116679 803716363 143446174 73783352 543037471 428078541 138246404 195802330 115853686 101418585 710033319 621123812 547981829 418923006 171169382 93217750 721102012 806509194 913407750 299610854 522334256 725299090 17656603 198739572 782551046 338961280 689847985 712835380 684239055 266307030 503217411 65581023 406935333 472049358 532089735 531912997 246634699 735197165 506445417 207775983 313838317 860702440 111515729 825140901 105051307 960860385 84084430 361146226 313534881 23616341 511106494 324904643 652159399 184155911 259…
Output: 8

Example 2:

Input: 1230 743174592 540457861 244349157 337837944 741031028 445664902 204218745 786124218 524023893 966907671 363227250 542040274 363285815 731566110 323673594 438910871 554410555 227547379 630077945 165883560 96447090 90397070 782048058 531943142 941106495 750589527 866234486 372462183 823459791 203002070 933430695 470819049 363677591 864655948 556480256 715871748 327993246 147602050 707889670 342914254 893211748 744213655 682139556 942565830 730547610 106354631 245605895 439832983 321263363 711329685 935824521 236185879 821351065 91408561 360065367 957450782 126514792 224849776 657777352 401629696 63503422 921276496 256128685 685600333 705262291 799702129 573354195 380809402 989494658 564943201 185052112 275886292 684269709 961427029 822733053 797435500 647423881 207428053 502842864 125758982…
Output: 8

Example 3:

Input: 88 92745617 726329669 282747987 721111529 861113238 575086227 705146609 647828585 549792566 378316972 355943333 249446104 229517039 524964746 732165965 998076164 10541246 548084876 100612666 979420062 116915016 330102056 424768748 828653494 857292446 250705355 251735339 90147228 626002303 62804813 632833095 46244895 524601483 306305514 438310435 608735068 778634117 749326100 106382267 379910509 217583649 298340499 495963633 767254221 707319747 572914612 697646746 84560103 208079576 452326270 470933422 386681210 797940570 379468317 473520894 53414707 174612500 840161713 615173516 637668432 897437525 744535913 839294915 756292389 332023789 557873447 555630983 483879016 590972544 59724887 726394535 373457298 739206348 889591765 801732806 716139490 294125235 958353380 64993435 570988655 431546…
Output: 7

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Roving scrolls Checker Stretch - MEDIUM Coding Problem | CodeTikki