Search
⌘K

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:

Google

Google


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid January, 2025

Google

Google

Mid-level

Calculate average server latency for last K values, ignoring top X values in a window of size K+X

Late December, 2024

Google

Google

Mid-level

Finding MK Average

Comments

Your account is free and you can post anonymously if you choose.