Solved LeetCode program · 356 of 1,000
#0480 · Sliding Window Median
Original English source
The numbers is a list of 1, 3, -1, -3, 5, 3, 6, 7. The width is 3. The last is the last position of numbers. The limit is last minus width plus 1. The medians is an empty list of whole numbers.
For every start from 0 to limit.
The window is a list of item start of numbers, item (start plus 1) of numbers, and item (start plus 2) of numbers. Sort window. The middle is width divided by 2. Place item middle of window into medians.
For each value in medians, show value.
Expected stdout
1 -1 -1 3 5 6