Preview build — question counts, lessons, and company notes on this site are placeholder data, not verified interview content.
Indwar

Longest window with at most k distinct values

CodingMediumCorroborated · 4 reportsLast seen Aug 19, 2026

The question

Given an array and an integer k, return the length of the longest contiguous window containing at most k distinct values. Follow-up: return the window itself, and handle a streaming input where you cannot revisit earlier elements.

No write-up yet

We have the question but not yet a full breakdown. If you were asked this, the fastest way to improve the page is to say what the interviewer pushed on.

Add what you remember →

4 people reported this question.

I was asked this too

Also reported at Anthropic, Perplexity, xAI.

Study the fundamentals: Core coding patterns