340-Longest-Substring-With-At-Most-K-Distinct-Characters
Sat 17 May 2025
https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def lengthOfLongestSubstringKDistinct(self, s: str, k: int) -> int:
ans = 0
distinct = 0
count = Counter()
l = 0
for r, c in enumerate(s):
count[c] += 1
if count[c] == 1 …Category: leetcode
Read More