Question bank › Sliding Window
Dsa Sliding Window Medium

Count Unique Elements in K Length

You are given an array of integers and an integer k. Your task is to count the number of unique integers in every contiguous subarray of length k. The first line of input consists of n (the size of array), followed by the integers of the array, and lastly the integer k. Output a list of integers representing the count of unique integers for each step over the array. Example: Input: 6 1 2 1 3 4 3 3 Output: 3 3 2

Key concepts

sliding_windowcounting

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.