LeetCode #3090

Maximum Length Substring With Two Occurrences

1개의 풀이 · Python

문제 원문 보기 ↗

SOLUTION INFO

Python · main.py

main.py
class Solution:
    def maximumLengthSubstring(self, s: str) -> int:
        D = defaultdict(int)
        N = len(s)
        r = -1
        answer = 0
        for l in range(N):
            while r + 1 < N and D[s[r + 1]] < 2:
                r += 1
                D[s[r]] += 1

            answer = max(answer, r - l + 1)
            D[s[l]] -= 1

        return answer

SOLUTION DESCRIPTION

풀이 설명

등록된 풀이 설명이 없습니다.