CT25081

Crimson scrolls Zigzag Stretch

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The accountant Quartermaster has been asked to decode the foreman's shorthand notes. On the desk lies a long table of scrolls readings. 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 <= 1014; -1000000 <= a[i] <= 1000.

Example 1:

Input: 517 -467841 -232906 -42652 -568098 -728753 -551885 -51687 -429140 -894415 -730481 -928923 -490681 -999156 -315031 -574988 -371103 -377009 -838223 -513323 -94267 -728725 -5286 -363622 -33860 -941193 -944037 -246276 -11783 -174542 -447068 -311861 -171005 -103886 -328647 -562199 -523040 -18692 -16167 -470717 -839822 -425828 -302755 -712520 -279010 -883413 -534735 -397485 -310405 -238072 -242507 -101415 -166929 -855616 -496853 -179359 -626941 -977384 -964273 -117619 -794351 -861539 -539267 -341114 -827367 -824836 -823046 -421458 -615845 -7777 -588769 -990467 -89425 -264014 -742178 -857255 -903150 -788134 -621630 -905204 -24946 -7714 -314154 -178901 -343019 -462840 -490144 -864925 -636858 -390002 -542741 -563821 -853551 -765853 -862878 -203915 -426089 -344629 -403992 -636727 -404431 -996951 -50…
Output: 517

Example 2:

Input: 1003 -778931 -589986 -193906 -597711 -748096 -673993 -311681 -376400 -985436 -258577 -101401 -548741 -263470 -762169 -205991 -416794 -722737 -317454 -691052 -114403 -363602 -772711 -262204 -464991 -48781 -917873 -892416 -777031 -385637 -344660 -565039 -224067 -457010 -296237 -61579 -600397 -464656 -424145 -73304 -993410 -104678 -143268 -126168 -673141 -964307 -966844 -524940 -87260 -660579 -454805 -522271 -199111 -218700 -66107 -852259 -761374 -584003 -804216 -732942 -620948 -453279 -254687 -275506 -867384 -453229 -531526 -995120 -277240 -76997 -883668 -306800 -924717 -308873 -878810 -432251 -474893 -481591 -52800 -725521 -5416 -465763 -444531 -24125 -444516 -278522 -386300 -658236 -895198 -136201 -41009 -448011 -530866 -409452 -584055 -813060 -948101 -332444 -851090 -166264 -452792 -53468…
Output: 1003

Example 3:

Input: 423 -94366 -850523 -403785 -253602 -574061 -725809 -157682 -571408 -796220 -479859 -913930 -509314 -868128 -344893 -43916 -403184 -134578 -29163 -637422 -871363 -414587 -327660 -719538 -55354 -616740 -644196 -738920 -772785 -580706 -222013 -155551 -114160 -522338 -528308 -380824 -741604 -299217 -143740 -540796 -423469 -522265 -759844 -122619 -850821 -245259 -284850 -437153 -396192 -830914 -100904 -814692 -627045 -606814 -944007 -160612 -521160 -963953 -301935 -306542 -479239 -188000 -761797 -531447 -569437 -162667 -399620 -111957 -695702 -440500 -380954 -323082 -49026 -790998 -461967 -857689 -559316 -957510 -163563 -602854 -460337 -588969 -95634 -196029 -846062 -636921 -810365 -820141 -542822 -646590 -254175 -574398 -285686 -372472 -939315 -680011 -224772 -123778 -463116 -719406 -250755 -2…
Output: 423

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Crimson scrolls Zigzag Stretch - EASY Coding Problem | CodeTikki