Interview Query

Moving Window

10
Have you seen this question before?

Given a list of numbers nums and an integer window_size, write a function moving_window to find the moving window average.

Example 1:

Input:

nums = [1,2,3,4,5,6]
window_size = 3

Output:

def moving_window(input, window_size) -> [1, 1.5, 2, 3, 4, 5]

Example 2:

Input:

nums = [1,2,3,4,5,6]
window_size = 4

Output:

def moving_window(input, window_size) -> [1, 1.5, 2, 2.5, 3.5, 4.5]
Next question: Meta in an Emerging Market
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code