Leetcode 1825. Finding MK Average
Maintain a sliding window of the last m stream elements and, after discarding the smallest k and largest k values, return the integer average of the remaining elements (return -1 if fewer than m elements). The core challenge is to support addElement and calculateMKAverage efficiently by keeping ordered partitions and their sums (e.g., via balanced BSTs/multisets or heaps with counts).
Asked at:
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid March, 2026
Meta
Senior
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the average for each k size window. Basically instead of maximum in original leetcode, you need average. So no monotonic deque needed, use accumulate sum and get average in each k size window
Mid January, 2025
Mid-level
Calculate average server latency for last K values, ignoring top X values in a window of size K+X
Hello Interview Premium
Your account is free and you can post anonymously if you choose.