Tap here to switch tabs
Problem
Submissions

Problem: Delayed Count of Equal Elements

Delayed Count of Equal Elements asks you to return an array where each position records how many later elements have the same value and are separated from it by more than k positions.

Statement

You are given a 00 indexed integer array nums of length n and a non negative integer k.

For each index i where 0≤i<n0 \leq i < n, find the number of indices j that satisfy:

  • i+k<j<ni + k < j < n

  • nums[j] == nums[i]

Return an integer array ans of length n, where ans[i] is the count of such indices j for each i.

Constraints:

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

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

  • 0≤k≤n−10 \leq k \leq n - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Delayed Count of Equal Elements

Delayed Count of Equal Elements asks you to return an array where each position records how many later elements have the same value and are separated from it by more than k positions.

Statement

You are given a 00 indexed integer array nums of length n and a non negative integer k.

For each index i where 0≤i<n0 \leq i < n, find the number of indices j that satisfy:

  • i+k<j<ni + k < j < n

  • nums[j] == nums[i]

Return an integer array ans of length n, where ans[i] is the count of such indices j for each i.

Constraints:

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

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

  • 0≤k≤n−10 \leq k \leq n - 1