Tap here to switch tabs
Problem
Submissions

Problem: Subarrays Where Max Element Appears at Least K Times

med
30 min
Try to solve the Count Subarrays Where Max Element Appears at Least K Times problem.

Statement

Given an integer array nums and a positive integer k, return the total number of subarrays where the maximum element of nums appears at least k times.

Constraints:

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

  • 1≤1 \leq nums[i] ≤106\leq 10^6

  • 1≤1 \leq k ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Subarrays Where Max Element Appears at Least K Times

med
30 min
Try to solve the Count Subarrays Where Max Element Appears at Least K Times problem.

Statement

Given an integer array nums and a positive integer k, return the total number of subarrays where the maximum element of nums appears at least k times.

Constraints:

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

  • 1≤1 \leq nums[i] ≤106\leq 10^6

  • 1≤1 \leq k ≤105\leq 10^5