1852. Distinct Numbers in Each Subarray
https://leetcode.com/problems/distinct-numbers-in-each-subarray
Description
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
.
Example 1:
Example 2:
Constraints:
1 <= k <= nums.length <= 105
1 <= nums[i] <= 105
ac
Last updated