Counting Subarrays Where the Max Appears At Least K Times (LeetCode 2962)
Problem Summary You’re given an integer array nums and a number k. Your task is to count the number of subarrays where the maximum element of the entire array appears at least k times. Sliding Window to the Rescue This is a classic case where brute force (O(n²)) would time out. The key to optimizing…