Question bank › Sliding Window
Dsa Sliding Window Easy

Count Distinct Integers in Window

Given an array of integers and an integer K, count the number of distinct integers in every contiguous subarray of length K. You must read the input as a single line where the first integer is the length of the array followed by the elements of the array and then the integer K. Example: Input: 5 1 2 1 3 4 3 Output: 3 3 2

Key concepts

sliding_windowcountingdistinct

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.