CT34464

The Palemere Zigzag Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the salt flats of Palemere opens only for a perfect tally of windows. Emir means to find out. 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 <= 2579; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 1279 -404397 -656076 -304895 -199127 -925625 -322407 -803332 -283422 -652158 -254229 -353007 -579911 -251387 -483451 -450750 -24700 -272422 -25979 -280202 -692303 -282350 -85420 -652818 -742599 -764700 -535598 -208690 -702336 -805185 -589439 -15901 -585374 -862580 -450653 -450161 -380664 -343668 -652822 -699873 -586447 -987803 -559645 -46385 -377431 -461738 -338753 -139363 -807531 -533879 -532714 -195449 -565744 -420612 -908996 -764933 -912178 -128844 -620579 -130804 -828645 -984199 -882601 -642864 -662559 -857118 -571640 -21821 -810544 -117538 -612465 -77372 -448163 -272864 -181560 -729240 -600401 -399564 -455947 -40467 -758277 -91192 -986953 -521444 -102278 -937185 -659760 -66681 -169306 -686583 -91778 -773212 -621143 -871569 -849108 -872340 -811632 -540283 -182354 -213176 -860997 -19956…
Output: 1279

Example 2:

Input: 1789 -461836 -441839 -755680 -181581 -40174 -220329 -875297 -235001 -468267 -307881 -598493 -282310 -285986 -562385 -10215 -334389 -619243 -944544 -122243 -960851 -620910 -96730 -996520 -886852 -137294 -903494 -567366 -682368 -442364 -302029 -373891 -976020 -301433 -529169 -949321 -672615 -765853 -650614 -162088 -900504 -228039 -803647 -765280 -905695 -619773 -826888 -996495 -73306 -686519 -610819 -967654 -904276 -383412 -200541 -864443 -28701 -43023 -219037 -271783 -182456 -900640 -682245 -80219 -253289 -467221 -160660 -723129 -564272 -724646 -400751 -499946 -136668 -785657 -893891 -136941 -78247 -762899 -453975 -656755 -42847 -23276 -536357 -218240 -622323 -765071 -284019 -501415 -449283 -42792 -128051 -249109 -643480 -367065 -843137 -897409 -204882 -214000 -345578 -714238 -573860 -88170…
Output: 1789

Example 3:

Input: 599 -807661 -528404 -477823 -163257 -178693 -157713 -617179 -402597 -781751 -190504 -134211 -939521 -840770 -642122 -571889 -730304 -603893 -994647 -467455 -927406 -103532 -876959 -632237 -896011 -538441 -463197 -993123 -934246 -238780 -95037 -135753 -547394 -969773 -332642 -782431 -274809 -718368 -55283 -403319 -429264 -583833 -859413 -537063 -532547 -602144 -94491 -546525 -524539 -464798 -878715 -133135 -313934 -237255 -64857 -112448 -56544 -896057 -677051 -999236 -167195 -468113 -575446 -501362 -221208 -638012 -623187 -281257 -334175 -544569 -567806 -203540 -729288 -253685 -558308 -255385 -645621 -277897 -885858 -35732 -631034 -58958 -633497 -411326 -243483 -655901 -817878 -851198 -506127 -843544 -333365 -64825 -742252 -599877 -950603 -218644 -623427 -176186 -759234 -686509 -485610 -109…
Output: 599

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Palemere Zigzag Stretch - MEDIUM Coding Problem | CodeTikki