NumPy allowed · plain Python earns 10 bonus points
Implement an O(n) moving average window filter by maintaining incremental running sums.
Implement sliding_window_average(nums, k): calculate the moving average for each continuous sub-array of length k across nums. Each mean must be rounded to 4 decimal places. If len(nums) < k or k <= 0, return [].
sliding_window_average(nums: list[float], k: int) -> list[float]