CT32137

Anaya and the Whispering ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Anaya inherited the foundry at the frontier camp of Duskwood along with its curious bookkeeping system for ribbons. Time to make sense of it. 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 <= 2625; -1000000 <= a[i] <= 1000.

Example 1:

Input: 550 -162081 -859273 -297841 -884024 -416314 -49165 -865894 -927775 -78949 -857709 -95688 -226877 -525863 -792539 -856762 -13894 -266049 -271095 -546240 -852606 -35387 -498224 -823385 -584401 -831658 -689797 -555432 -876474 -863480 -691045 -685608 -149927 -54162 -234924 -360980 -73682 -313409 -211495 -766005 -623582 -378345 -431773 -875855 -355953 -400225 -334244 -844909 -598653 -263209 -936855 -50715 -403054 -641017 -714377 -676061 -134885 -438268 -91309 -729087 -462931 -979408 -759579 -532042 -356476 -733525 -408866 -53286 -282419 -637767 -664316 -384836 -885106 -844383 -210688 -738023 -85649 -101097 -514933 -918019 -341877 -799519 -637064 -478953 -115573 -385993 -370898 -275215 -204674 -880258 -732591 -416918 -847186 -268450 -585049 -609306 -692473 -771131 -935453 -267242 -301167 -891103…
Output: 550

Example 2:

Input: 220 -506705 -397355 -59915 -865500 -819469 -233054 -881213 -959056 -286969 -591938 -83963 -968982 -701221 -269663 -600220 -709109 -862115 -56780 -804881 -92379 -999200 -611227 -178573 -854423 -537335 -775742 -615434 -136760 -110600 -191849 -908380 -204275 -918861 -419335 -989520 -464677 -252012 -232469 -926075 -712522 -482593 -310905 -12414 -248643 -940907 -856323 -943844 -371040 -149756 -328431 -309355 -784981 -604140 -319276 -558364 -36703 -809587 -325917 -47976 -981326 -173715 -813861 -128336 -875851 -257641 -577827 -45175 -416687 -435409 -686618 -457463 -208550 -946829 -792528 -390039 -917823 -954099 -707545 -629365 -708728 -737043 -174005 -520335 -484955 -928932 -180605 -62296 -975885 -793935 -477136 -955441 -468867 -164269 -700391 -229851 -692637 -879200 -323814 -210544 -384721 -7806…
Output: 220

Example 3:

Input: 726 -234945 -144704 -460382 -755714 -878611 -289318 -605914 -845268 -185947 -587965 -215072 -460880 -582745 -801036 -428594 -782267 -828411 -383185 -259495 -545078 -526201 -791777 -763250 -844835 -641727 -472384 -226867 -991806 -229346 -71541 -27476 -101479 -457969 -865377 -301953 -397150 -757227 -33025 -417258 -273401 -974654 -675640 -985958 -24337 -332702 -465531 -566224 -926324 -546467 -555513 -337208 -879635 -414523 -102631 -269316 -425834 -203468 -940945 -147420 -682887 -338112 -864466 -75025 -140737 -164010 -593410 -93246 -796009 -679664 -648835 -404570 -320738 -643652 -386069 -578916 -950576 -300817 -247506 -314999 -915302 -659087 -592062 -846595 -232655 -954016 -293428 -121091 -773060 -313185 -551191 -807876 -292875 -138234 -105535 -448262 -26473 -624680 -106827 -867422 -211692 -18…
Output: 726

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Anaya and the Whispering ribbons - MEDIUM Coding Problem | CodeTikki