Code Room
CodingHard
Question
Given an integer array nums and window size k (1 <= k <= len(nums)), return the median of each contiguous window of size k as a list of floats, left to right. The median of an even-sized window is the average of its two middle elements. Aim for better than O(n*k log k).
Implement
sliding_window_median(nums: list[int], k: int) → list[float]Examples
in
[[1,3,-1,-3,5,3,6,7],3]out[1,-1,-1,3,5,6]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.