#K83887. Find Plateaus in a Sequence
Find Plateaus in a Sequence
Find Plateaus in a Sequence
You are given a sequence of n integers representing the heights at consecutive points. A plateau is defined as a contiguous subsequence where the height remains constant for at least two consecutive points. Your task is to find all plateaus in the sequence and output the starting and ending indices (1-indexed) of each plateau.
If there is no plateau in the sequence, output the string No Plateaus
.
Note: The indices in the output are 1-indexed.
inputFormat
Input is read from standard input (stdin). The first line contains an integer n representing the number of points. The second line contains n space-separated integers representing the heights.
outputFormat
If one or more plateaus are found, output each plateau on a new line with two space-separated integers denoting the start and end indices of that plateau. If no plateaus are found, output No Plateaus
.
10
1 2 2 2 3 4 4 2 2 1
2 4
6 7
8 9
</p>