CT34639

Curator's Sable stretches

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Curator the cartographer watches over the glass towers of Prismhaven's stores of stretches. A careful computation stands between order and chaos. 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 <= 1704; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 85 -734740 -779766 -334368 -377838 -701707 -37739 -575478 -295057 -254700 -432052 -37810 -674986 -907310 -953851 -187891 -456366 -69173 -513766 -161704 -55517 -756001 -495247 -209707 -849591 -54523 -941504 -848236 -74419 -904668 -429429 -481001 -844688 -170512 -664791 -884799 -447665 -125348 -151674 -4860 -803631 -359375 -614637 -74160 -985858 -482339 -61178 -91964 -398143 -806808 -437501 -934367 -506486 -722771 -45805 -95494 -312039 -649593 -500226 -881027 -777973 -827354 -709597 -756792 -758711 -806655 -945490 -456054 -853131 -997177 -376859 -897908 -235845 -256631 -273106 -592621 -337338 -870103 -81720 -158010 -820974 -918570 -911037 -279916 -729222 -384025
Output: 85

Example 2:

Input: 996 -916527 -709269 -382364 -117582 -876837 -616942 -169437 -882185 -162307 -299636 -549160 -794898 -215480 -59137 -230060 -587228 -895046 -514658 -906345 -99569 -796873 -816669 -423817 -413339 -729427 -534625 -372068 -325868 -612647 -694722 -534345 -57296 -759386 -443814 -633668 -175185 -315625 -533680 -926880 -631349 -68163 -908307 -483860 -823914 -691032 -81111 -81210 -386794 -953747 -688960 -954179 -780839 -830544 -791186 -713949 -526875 -403070 -748844 -103997 -364301 -385655 -31701 -247312 -655177 -781654 -950264 -16979 -142162 -89113 -751811 -260017 -279132 -149309 -627720 -901175 -910778 -686221 -724534 -791532 -330929 -244653 -317139 -405328 -962779 -55692 -882151 -412592 -527619 -145457 -843260 -472834 -861250 -216967 -454016 -955508 -800999 -371679 -141884 -885835 -965026 -71831…
Output: 996

Example 3:

Input: 1266 -483092 -973826 -203575 -736819 -544751 -350760 -475882 -646560 -23236 -393709 -390369 -654388 -734489 -250290 -556151 -603419 -560151 -613029 -505055 -552508 -3055 -923581 -94305 -796487 -960601 -147926 -933092 -271633 -704197 -786517 -339744 -69181 -395951 -985059 -484445 -706732 -579576 -168020 -881956 -602677 -717786 -716079 -867334 -140760 -475435 -339277 -572098 -590986 -115365 -379554 -26131 -148990 -175237 -696362 -262359 -358740 -653196 -874097 -993033 -382151 -910196 -793467 -979299 -878106 -974579 -518416 -589890 -131621 -483652 -301678 -263869 -766885 -615810 -805967 -677621 -109981 -621363 -140659 -964223 -467830 -186726 -485192 -828014 -226922 -612642 -418549 -10125 -423796 -221447 -392134 -667247 -759063 -880396 -84165 -863601 -710191 -829121 -642389 -277692 -804733 -93…
Output: 1266

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Curator's Sable stretches - MEDIUM Coding Problem | CodeTikki