Back to problems

Windowed Average excluding Largest K

Algorithm · Google · Hard

Given an integer array nums, a window length windowSize, and an integer k, produce the averages of all contiguous windows of length windowSize, processing those windows from left to right. For every window, leave out its k greatest values before computing the average. Constraints 1 Input: nums = [10, 20, 30, 40, 50, 60], windowSize = 3, k = 1 Output: [15.0, 25.0, 35.0, 45.0] Explanation: - For [10, 20, 30], remove 30 as the largest value; (10 + 20) / 2 gives 15.0. - For [20,…

Checking your access…