Practice Count Subarrays Where Max Element Appears at Least K Times
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#2962
LeetCode ProblemCount Subarrays Where Max Element Appears at Least K Times
Problem Statement
You are given an integer array nums and a positive integer k. Return the number of subarrays where the maximum element of nums appears at least k times in that subarray. A subarray is a contiguous sequence of elements within an array.
Source: Count Subarrays Where Max Element Appears at Least K Times on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,3,2,3,3], k = 2
Output
6
# Example 2
Input
nums = [1,4,2,1], k = 3
Output
0
Constraints
1 <= nums.length <= 10^5
1 <= nums[i] <= 10^6
1 <= k <= 10^5
Related LeetCode Problems
Practice more problems similar to Count Subarrays Where Max Element Appears at Least K Times.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.