cde or pqrst. Strings such as ace, dc or za are not alphabetical: the alphabet does not wrap around after z.
Given a string text of lowercase English letters, return the length of its longest substring (contiguous piece) that is alphabetical.
A single letter on its own is an alphabetical string of length 1.text="xyzabcdmn" → 4
The runs of consecutive letters are xyz (3), abcd (4) and mn (2). The longest is abcd. The alphabet does not wrap after z, so za does not count.
text="kkk" → 1
Equal letters are not neighbours in the alphabet, so every run is a single letter.
text="fghij" → 5
text consists of lowercase English letters onlytext="xyzabcdmn"
4
Run checks the first 3 tests in your browser. Submit checks all 117 tests on the server, hidden ones included.