Available question text
Given a string, find the length of the longest contiguous substring that contains at most two distinct characters — a sliding-window / two-pointer problem where you track character frequencies to maintain at most two active characters and achieve linear time.
Related questions
Continue with questions that share topics or the same question type.
- Longest Substring with At Most K Distinct Characters
Coding · Hash Table · Sliding Window · String
- Longest Substring with K Distinct Characters
Coding
- Largest Substring Between Two Equal Characters
Coding
- Longest Common Anagram Substring in Two Strings
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 159. Longest Substring with At Most Two Distinct Characters
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source