2414. Length of the Longest Alphabetical Continuous Substring

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2414

class Solution:
    def longestContinuousSubstring(self, s: str) -> int:
        res = 0
        i, j = 0, 1
        while j < len(s):
            res = max(res, j - i)
            if ord(s[j]) - ord(s[j - 1]) != 1:
                i = j
            j += 1
        res = max(res, j - i)
        return res