#C11825. Longest Non-Decreasing Substring
Longest Non-Decreasing Substring
Longest Non-Decreasing Substring
You are given a string s of length n consisting of lowercase Latin letters. Your task is to determine the length of the longest contiguous substring of s in which the characters are in non-decreasing order. In other words, find the maximum length of a substring that satisfies the condition:
\( s[i] \leq s[i+1] \quad \text{for all valid } i \)
For example, if s = "abcabc"
, the longest non-decreasing substring is "abc" which has length 3.
Pay careful attention to edge cases such as strings with a single character or strings where the order is strictly decreasing.
inputFormat
The input is given from stdin and consists of two lines:
- An integer n representing the length of the string.
- A string s of length n containing only lowercase Latin letters.
outputFormat
Print to stdout the length of the longest non-decreasing contiguous substring of s.
## sample6
abcabc
3
</p>