Problem · Array

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

EasyMetaFULLTIMEPHONE SCREEN
See Meta hiring insights

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 :)

Examples
01 · Example 1
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]
windowSize = 7
return = [4.0, 5.0, 6.0]
KEEP SMILING :))
More Meta problems
drafts saved locally
public double[] slidingWindowAverage(int[] nums, int windowSize) {
  // write your code here
}
nums[1, 2, 3, 4, 5, 6, 7, 8, 9]
windowSize7
expected[4.0, 5.0, 6.0]
sign in to submit