Fixed-Window Rolling Mean
Updated
Problem statement
Given an integer array nums and a positive windowSize, return the arithmetic mean of every complete contiguous window of that size, from left to right.
Update the running window in constant time as it advances.
Function
fixedWindowRollingMean(nums: int[], windowSize: int) → double[]Examples
Example 1
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]windowSize = 7return = [4.0, 5.0, 6.0]The three complete windows have sums 28, 35, and 42; dividing each by 7 gives the returned means.
Constraints
nums.length >= 11 <= windowSize <= nums.length- The result contains exactly
nums.length - windowSize + 1averages, one for each contiguous window.
More Jump Trading interview questions
Similar questions at other companies
- Bad Request AlertsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Sliding Window Average (Meta Canada, E4/E5 :)Meta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Maximum Earnings Across WarehousesAmazon · ONSITE INTERVIEW
- Shortest Subarray with Sum at Least KOracle · ONSITE INTERVIEWOracle interview questions
- Longest Subarray Within an Absolute-Difference LimitGoogle · ONSITE INTERVIEWGoogle interview questions
- Longest Continuous Subarray Within an Absolute-Difference LimitUber · ONSITE INTERVIEWUber interview questions
- Sliding-Window Rate LimiterSnowflake · ONSITE INTERVIEWSnowflake interview questions
- Sliding Window MaximumPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
- Sliding Window MaximumBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Moving Average of a Data StreamSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions