CT22586

Chetan's Crystal Ledger

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Deep in the ivory gates of Alabast, Chetan studies rows of segments entries. One clean number will settle the guild's oldest argument. 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 <= 800; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 501 728531491 841469678 595535044 969785793 14718636 882318286 184601471 379574969 785026927 14074099 89322677 74294965 522623674 990610279 618442279 461688376 774867018 60512175 863942139 980388805 823156949 813559270 165728735 403952925 274646344 513920258 313698515 686842975 751571803 564165854 819519777 761040603 406737265 308830515 22039264 51929144 597663410 756798224 203163499 760370804 307090729 23178691 35723182 937354874 660380851 280298562 826541286 91900974 243666822 673759824 415781236 426633795 932128923 432181239 527482578 797515678 18250400 681508698 588709095 471549295 381615660 495567263 791763339 890272564 91779497 8656802 123955205 257936626 580887912 249244356 796457872 100542081 967484034 704416731 158100634 825244537 779566881 709773324 144599731 110108275 145937924 …
Output: 9

Example 2:

Input: 638 929761040 25174013 60253512 420613549 446281428 678370907 234014585 486767033 437761802 725949447 902497810 601253790 569543807 150014587 918609046 834146795 669001997 809623602 437849189 495413636 703873258 736779939 29268742 250396517 753517916 117018973 793415343 693970048 445811429 3568961 692158674 781401478 824404465 880266817 730027418 810437854 645777149 59193199 463001706 749917311 869534164 929834291 5312918 969860554 706160124 763702580 530477201 293105097 236494486 317014975 247188255 516707600 322071660 726187316 573934858 722395291 317521755 496872106 669003351 137621269 869877851 522192006 925049649 82564179 228048121 682082530 600620467 495476526 902521172 400615563 875211966 386378127 118315788 120609148 843956941 305685289 486226994 343418907 997773114 910007519 21973…
Output: 7

Example 3:

Input: 364 516771077 534863005 200499342 226036130 258101938 161756193 491410666 155032843 425211642 866134781 541888784 605636917 296401089 492508402 841492792 904086259 541436034 622854383 973733718 182036241 273816662 554411043 217542866 361602161 913350492 841864696 679017931 214502176 96929759 446158889 339378868 895299310 658898042 433628233 616338119 840383534 402362964 387886712 239876327 384223499 952365880 728174729 537550564 611661165 471617345 655997578 544834769 485553976 119310857 96947285 97668683 285767316 616937455 13241238 544474178 780945850 709305455 817706856 814145826 663236517 589548020 917973166 954269787 151411604 528450564 822923159 636466215 991129162 721556195 874621270 558346998 219438540 252100733 345786746 32462457 446931179 571515603 861741257 171730066 467175736 4…
Output: 11

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Chetan's Crystal Ledger - EASY Coding Problem | CodeTikki