Dsa
Sliding Window
Medium
Sliding Window Median
Given an array of integers nums and an integer k, find the median of each sliding window of size k. The median is defined as the middle value in a list of numbers.
Example:
Input:
[1, 3, 2, 5, 4], 3
Output:
[2.0, 3.0, 4.0]
(Note: The medians for [1, 3, 2], [3, 2, 5], [2, 5, 4] are 2, 3, and 4.)
Key concepts
sliding_windowmediandeque
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now