Sliding window range
Your task
Given an integer array nums and a window size k, return for each window the difference (max - min) within that window, as you slide the window from left to right one step at a time. The array has length between 1 and 10^5 and 1 <= k <= len(nums). Return a list of length len(nums) - k + 1.
Examples
window_range(nums: list[int], k: int) -> list[int]Example 1
Input
window_range([1, 3, -1, -3, 5, 3, 6, 7], 3)Output
[4, 6, 8, 8, 3, 4]