CT24793

The Zigzag Stretch at Greystone

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The harbor bell rings at the shale slopes of Greystone; Diya weighs the day's stretches manifests and starts the calculations. Task: Print the length of the longest contiguous run in which every two consecutive elements differ. Input format: First line: n. Second line: n integers. Output format: Print the maximum alternating run length. Constraints: 1 <= n <= 1888; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 146 -956086 -219043 -941767 -687872 -606876 -411596 -301109 -639864 -743092 -665491 -760634 -133339 -851707 -934964 -202504 -769309 -25903 -946407 -908899 -888205 -806575 -87489 -524448 -533020 -404908 -528088 -537889 -665778 -473713 -585701 -402948 -613728 -487641 -545016 -347837 -973914 -990711 -180590 -644502 -976267 -242944 -535929 -484994 -785236 -169227 -539173 -576062 -756618 -898014 -735758 -135101 -305545 -693497 -342122 -133806 -290403 -614837 -773355 -807905 -159945 -662124 -171337 -431217 -730331 -823517 -358735 -620710 -672510 -983298 -252760 -770163 -945208 -410842 -17830 -432618 -32660 -168663 -385963 -555206 -113143 -997483 -267553 -482238 -975042 -525834 -575327 -525017 -363903 -505175 -858510 -968131 -242942 -486916 -158439 -22482 -556631 -392743 -846130 -872896 -882433 -…
Output: 146

Example 2:

Input: 602 -895873 -99041 -716168 -875109 -920267 -262326 -112505 -646567 -52806 -570604 -486625 -911901 -7390 -47881 -264176 -25603 -627765 -398937 -231175 -249097 -751696 -369652 -403821 -23522 -846948 -572196 -706999 -862235 -521348 -412797 -325189 -185884 -653324 -110148 -505455 -635957 -671423 -398314 -173099 -348591 -979100 -600954 -983791 -678630 -393315 -830321 -692527 -281186 -664983 -854082 -813660 -828393 -295602 -493148 -88644 -993302 -733359 -675445 -106405 -161331 -791120 -288865 -954544 -8320 -321347 -433196 -355695 -701975 -141026 -844592 -483695 -404428 -838308 -838765 -863407 -753625 -792726 -429281 -137855 -110591 -605517 -594565 -587718 -165806 -746198 -618550 -275105 -399621 -241147 -826562 -706362 -308925 -716155 -23348 -793875 -632055 -488031 -705052 -52227 -485501 -590289 …
Output: 602

Example 3:

Input: 1621 -618821 -268379 -771498 -691621 -426056 -82257 -47836 -280727 -844857 -115276 -805232 -384573 -786852 -622984 -222205 -898023 -668702 -778692 -726077 -332093 -685262 -511256 -15493 -272277 -513213 -113894 -156083 -248489 -200019 -496728 -915314 -955462 -668506 -605838 -48633 -365203 -482033 -846823 -685881 -221391 -703363 -180946 -712598 -984138 -278339 -806298 -683314 -645191 -934999 -81848 -95931 -97739 -615864 -124721 -152059 -457510 -741339 -802161 -263582 -141303 -894994 -382814 -472198 -416660 -933814 -422483 -69299 -954943 -128344 -508231 -104956 -756713 -257635 -845381 -32256 -691343 -248111 -286650 -395474 -445318 -838787 -87938 -207945 -202845 -742830 -763730 -911183 -704882 -856179 -785736 -804793 -199121 -492722 -83227 -824650 -989925 -380497 -389613 -755647 -192928 -16858…
Output: 1621

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Zigzag Stretch at Greystone - EASY Coding Problem | CodeTikki