Tap here to switch tabs
Problem
Submissions

Problem: Distinct Numbers in Each Subarray

Distinct Numbers in Each Subarray takes an integer array and window length, then returns how many different values appear in every contiguous subarray of that length.

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...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

Distinct Numbers in Each Subarray takes an integer array and window length, then returns how many different values appear in every contiguous subarray of that length.

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...i + k - 1].

Constraints:

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

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