CT30528

The Zigzag Stretch at Cascade Vale

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the ribbon falls of Cascade Vale as Milo unrolls the day's manifest of segments. The tally will decide the next shipment. 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 <= 2837; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 289 -890784 -859486 -598480 -426218 -738057 -938106 -992679 -634647 -672650 -808983 -338837 -507071 -499853 -983972 -741327 -25839 -166156 -98236 -599098 -839841 -837303 -25086 -751199 -480009 -520250 -156216 -155882 -863588 -383312 -62493 -793433 -480944 -225792 -290116 -188989 -199278 -577685 -722591 -152795 -510963 -639261 -897755 -439580 -960616 -287321 -842688 -563853 -975825 -566201 -743018 -669928 -404570 -783151 -706644 -811398 -631425 -624032 -542858 -500589 -141330 -657940 -382593 -875465 -328566 -948436 -732373 -23602 -861713 -334967 -2296 -805410 -535538 -787643 -481681 -860958 -897375 -38246 -509253 -532041 -427269 -828980 -312908 -813870 -586599 -878969 -780207 -649897 -333828 -838166 -872144 -231904 -341802 -638131 -495746 -370909 -125460 -364268 -740273 -434112 -841776 -553…
Output: 289

Example 2:

Input: 125 -9126 -800640 -877702 -791436 -554520 -907339 -564468 -289637 -144156 -801810 -719435 -562674 -469545 -511973 -753921 -864213 -123218 -760122 -63449 -554687 -993699 -302885 -144233 -899064 -515175 -254360 -263484 -254103 -490042 -887370 -966387 -23626 -555987 -532016 -738476 -35248 -747527 -345271 -426270 -310103 -133844 -279736 -113255 -124744 -132671 -634012 -848255 -356663 -921130 -612381 -56886 -207630 -982002 -150522 -545921 -65654 -126619 -844363 -111648 -164919 -322516 -894733 -741876 -855579 -859425 -39708 -641165 -553166 -857588 -286952 -984319 -963128 -722040 -35747 -359783 -775239 -575802 -207416 -212160 -818775 -289904 -881302 -102075 -827042 -997100 -812691 -744151 -616817 -659112 -355625 -427146 -492514 -437915 -743838 -521315 -54979 -942454 -610468 -715776 -359499 -90849…
Output: 125

Example 3:

Input: 2449 -430400 -718223 -894710 -839791 -181382 -977426 -380462 -325748 -824068 -909200 -703070 -93788 -501338 -664156 -483144 -421182 -962268 -616803 -559666 -727843 -705054 -621799 -766793 -798208 -483979 -843449 -576839 -561774 -136958 -435376 -16920 -753686 -134521 -757167 -491780 -281514 -953745 -951107 -193727 -616054 -697903 -851167 -493759 -96757 -515737 -173133 -291128 -228821 -290554 -588808 -511626 -36460 -919096 -24329 -543507 -941065 -907133 -142479 -911615 -23350 -245034 -56083 -274975 -840488 -228532 -634747 -647889 -456431 -977818 -235450 -313470 -226166 -828682 -604473 -432212 -239363 -169782 -883531 -718828 -765649 -32901 -939063 -727981 -392376 -978198 -478166 -996011 -247686 -808153 -724895 -518491 -434271 -266489 -393956 -983674 -960549 -457025 -329739 -952600 -591068 -85…
Output: 2449

Constraints:

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

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