#2414
Length of the Longest Alphabetical Continuous Substring
specialist · 715 · lc medium +30 · verified · 60.3% accepted · 553 likes · top 59%
Description
An alphabetical continuous string consists of consecutive letters of the alphabet (a substring of "abcdefghijklmnopqrstuvwxyz"). For example, "abc" qualifies but "acb" does not.
Given a string s, return the length of its longest alphabetical continuous substring.
Example 1:
Input: s = "abacaba"
Output: 2
Explanation: There are 4 distinct continuous substrings: "a", "b", "c" and "ab".
"ab" is the longest continuous substring.
Example 2:
Input: s = "abcde"
Output: 5
Explanation: "abcde" is the longest continuous substring.
Code
1
2
3