CT33589

The Topaz stretches of Jessa

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the mulberry rows of Silkmead, Jessa studies rows of stretches entries. One clean number will settle the guild's oldest argument. 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 <= 2299; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 943 -234497 -108836 -137787 -736942 -186786 -468288 -803993 -623399 -399073 -52241 -7059 -766652 -304184 -515601 -95143 -593082 -81438 -413355 -381806 -183346 -659616 -460532 -895878 -678986 -658481 -163249 -8186 -729631 -444435 -353474 -799445 -423552 -561200 -428709 -477618 -948501 -774524 -156744 -610170 -478299 -520267 -90454 -24910 -78821 -451409 -525757 -370100 -662261 -346810 -984568 -530154 -363005 -702820 -88764 -785550 -896132 -485398 -472279 -81925 -741154 -286021 -356450 -770417 -918902 -461802 -76172 -597611 -189160 -511388 -963988 -689397 -703197 -220848 -295611 -248763 -851277 -691172 -470546 -553248 -269319 -887592 -906694 -553699 -115966 -462478 -569313 -911856 -26521 -443763 -256150 -820832 -558217 -100201 -575788 -188249 -286236 -480431 -379845 -987070 -43144 -601379 -85…
Output: 943

Example 2:

Input: 1639 -758368 -343664 -560648 -28594 -521127 -65505 -497650 -584115 -472235 -936111 -176404 -438409 -148595 -775910 -149985 -308662 -510766 -893965 -968922 -281534 -325269 -15373 -29719 -514714 -604337 -698682 -322042 -852377 -657858 -65795 -414639 -852832 -223974 -684210 -334889 -988428 -474334 -21035 -596235 -86508 -857412 -822553 -970784 -624323 -102883 -219978 -198602 -240633 -313858 -592859 -604505 -36092 -522996 -982476 -70701 -610550 -272943 -998484 -333687 -353943 -364691 -810465 -563595 -667018 -17654 -77084 -60378 -874923 -967109 -954345 -618552 -152107 -874055 -869233 -89572 -860252 -996483 -334676 -928591 -922357 -424543 -798840 -41947 -957780 -726970 -286658 -909513 -861846 -819934 -382154 -141053 -654664 -592504 -779026 -583212 -90248 -619846 -485357 -881801 -644373 -736049 -3…
Output: 1639

Example 3:

Input: 2210 -939040 -721165 -978246 -653037 -931287 -353539 -100413 -231828 -821232 -174292 -468825 -210203 -350033 -240174 -494815 -81902 -827959 -929720 -917491 -233336 -837656 -163691 -36968 -177514 -53130 -847142 -408260 -422535 -158354 -549756 -446832 -9413 -402315 -156273 -601158 -288199 -137812 -578968 -429149 -242562 -468871 -579145 -767826 -497709 -296620 -433511 -483677 -932538 -856610 -190999 -293772 -301774 -292430 -933052 -779865 -755086 -451705 -149963 -710581 -169164 -159887 -654682 -285882 -74790 -820466 -892901 -827586 -212868 -647023 -770014 -946432 -895911 -327206 -554800 -352476 -674045 -492090 -218945 -156583 -30230 -462525 -396386 -897407 -466030 -357529 -845911 -828782 -388145 -148944 -8837 -686492 -932383 -854128 -287971 -348360 -335317 -450317 -870238 -899367 -51555 -1234…
Output: 2210

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Topaz stretches of Jessa - MEDIUM Coding Problem | CodeTikki