Question bank › Sliding Window
Dsa Sliding Window Warm-up

Max Length of Repeating Characters

Given a string `s`, find the length of the longest substring that contains at most two distinct characters. Input Format: - A single line containing the string `s` (1 <= |s| <= 10000). Output Format: - Print an integer representing the length of the longest substring with at most two distinct characters. Example: Input: abcba Output: 3 (The longest substring is "bcb".)

Key concepts

sliding_windowstringscounting

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.