Tap here to switch tabs
Problem
Submissions

Problem: Distinct Numbers in Each Subarray

med
30 min
Try to solve the Distinct Numbers in Each Subarray problem.

Statement

Given an integer array nums and an integer k, return an array ans of size nums.length −k+1- k + 1 where ans[i] is the number of distinct integers present in the subarray nums[i \dots i + k - 1].

Constraints:

  • 1≤1 \leq k ≤\leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Distinct Numbers in Each Subarray

med
30 min
Try to solve the Distinct Numbers in Each Subarray problem.

Statement

Given an integer array nums and an integer k, return an array ans of size nums.length −k+1- k + 1 where ans[i] is the number of distinct integers present in the subarray nums[i \dots i + k - 1].

Constraints:

  • 1≤1 \leq k ≤\leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5