← Questions

Sliding window median

0
MetaCodingLast asked Jul 2025

Given an array and a window size k, return the median of every window as it slides one step at a time. Keep two heaps (or a sorted container) and remove elements leaving the window, lazily if needed.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding