S
All challenges
Practice
Home
Blog
Practice
Examples
Feedback
Count Distinct Elements in Window
00:00
Start
00:00
Sign in
Problem
Hints
3
Solution
History
Medium
Array
Sliding Window
HashMap
Amazon
Google
Count distinct elements in every window of size k in an array.
Examples
Example 1
Input →
arr=[1,2,1,3,4,2,3], k=4
Output →
[3,4,4,3]
Example 2
Input →
arr=[1,2,3,4,5], k=3
Output →
[3,3,3]
Example 3
Input →
arr=[1,1,1,1], k=2
Output →
[1,1,1]
JavaScript
Python
Java (Coming soon)
C (Coming soon)
C++ (Coming soon)
Reset
Run
Submit
Cases
Results