FastPrepFastPrep
Problem Brief

Sliding Window Average (Meta Canada, E4/E5 :)

FULLTIMEPHONE SCREEN

Given an integer array as input and a window size, find the sliding window average.

Follow up: Design an API to return the sliding average, if input is given as a stream instead. Moving Average from Data Stream (This seems to be a LC question :)

1Example 1

Input
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9], windowSize = 7
Output
[4.0, 5.0, 6.0]
Explanation
KEEP SMILING :))
public double[] slidingWindowAverage(int[] nums, int windowSize) {
  // write your code here
}
Input

nums

[1, 2, 3, 4, 5, 6, 7, 8, 9]

windowSize

7

Output

[4.0, 5.0, 6.0]

Sign in to submit your solution.