Leetcode 480. Sliding Window Median
Given an array and window size k, return the median of each sliding window as it moves right by one. The core challenge is maintaining the median under online insertions and deletions efficiently (O(log k) per update) for n up to 1e5—typically solved with two heaps or a balanced multiset—and for even k the median is the average of the two middle values.
Asked at:
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late July, 2025
Meta
Senior
Early July, 2025
Meta
Senior
Late April, 2025
Meta
Mid-level
Your account is free and you can post anonymously if you choose.