1852. Distinct Numbers in Each Subarray
Given an integer array nums and an integer k, you are asked to construct the array ans of size n-k+1 where ans[i] is the number of distinct numbers in the subarray nums[i:i+k-1] = [nums[i], nums[i+1], …, nums[i+k-1]].
Return the array ans.
|
|
Constraints:
- 1 <= k <= nums.length <= 105
- 1 <= nums[i] <= 105
Solution
|
|