NeetCode #226LC-159MediumSliding WindowNC Algo100
← Back to All Problems

#226 · #159 · Longest Substring with At Most Two Distinct Characters(至多包含两个不同字符的最长子串)

📌 Problem Statement & Constraints

Given a string s, find the length of the longest substring that contains at most two distinct characters. Constraints: 1 <= s.length <= 10^4; s consists of ASCII characters.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!