Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

Given an array of integers nums and an integer k, compute the number of distinct numbers in every contiguous subarray (window) of size k. For each window, determine how many unique elements it contains and return these counts as an array.

Constraints:

  • 1 ≤ k ≤ nums.length
  • The array may include any integers (positive, negative, or zero).
Test Cases
Input
Output
Expected