Available question text
Given a string s and a non-negative integer k, find the length of the longest substring that contains exactly k distinct characters. Return -1 if no such substring exists.
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 At Most Two Distinct Characters
Coding
- Longest Substring with At Least K Repeating Characters
Coding
- Longest Substring Without Repeating Characters
Coding · Hash Table · Sliding Window · String
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
Adobe
Longest Substring with K Distinct Characters
Reported Jul 4, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source