CT33942

Iker's Solar Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Iker the chronicler watches over the frontier camp of Duskwood's stores of windows. 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 <= 1136; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 49 -226051 -362634 -725038 -97850 -527632 -662664 -909830 -680587 -804803 -34176 -485782 -281549 -917661 -338839 -668345 -842253 -181947 -496727 -746196 -416127 -334485 -32683 -688956 -56341 -72067 -583052 -128166 -108313 -969417 -65115 -406137 -701923 -855119 -841553 -224700 -471288 -773764 -116885 -550142 -668239 -433449 -159952 -326130 -452184 -520345 -167061 -239579 -960682 -88502
Output: 49

Example 2:

Input: 139 -208913 -365705 -60369 -971552 -127117 -719990 -721939 -946999 -162688 -675173 -93256 -338617 -597974 -938539 -545813 -25619 -431773 -238247 -183593 -614629 -405831 -255104 -904236 -221512 -297926 -899854 -540412 -570914 -272454 -41101 -448956 -77100 -6868 -458935 -788003 -830799 -391594 -368710 -809325 -719292 -234738 -332836 -864032 -568936 -795420 -804318 -378796 -794310 -811135 -181608 -264428 -36600 -639011 -47133 -228364 -611773 -509022 -467585 -997908 -13937 -836885 -649007 -556651 -659987 -150856 -69844 -287944 -515093 -606233 -146108 -126847 -684415 -919984 -90828 -767805 -643161 -323184 -126904 -527335 -164134 -759829 -937627 -127627 -147279 -661106 -757887 -616905 -826432 -250470 -441176 -283770 -516291 -109758 -144079 -750795 -154385 -960596 -999112 -373228 -111782 -421048 …
Output: 139

Example 3:

Input: 796 -512011 -888137 -283784 -24251 -533783 -696702 -332921 -5976 -490116 -585468 -487896 -241645 -118207 -975500 -428983 -756118 -665593 -608880 -38747 -808370 -816250 -461615 -143736 -888634 -893208 -39323 -702083 -697413 -959853 -79743 -98458 -376805 -576508 -397901 -798537 -208261 -656082 -484286 -928073 -745171 -648918 -913876 -489412 -188952 -871543 -170479 -930238 -996709 -138558 -892957 -914144 -145738 -50188 -285859 -512571 -492533 -137371 -11519 -468408 -17812 -503324 -997959 -744876 -449385 -127001 -63957 -647672 -664128 -159541 -689369 -910568 -778365 -295827 -62037 -378363 -983132 -116150 -63395 -783124 -414664 -610058 -865546 -553462 -654290 -588319 -381640 -708186 -671454 -461842 -507760 -345340 -837477 -970669 -46703 -789097 -989421 -725816 -101402 -641376 -362474 -374377 -2…
Output: 796

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Iker's Solar Ledger - MEDIUM Coding Problem | CodeTikki