Tap here to switch tabs
Problem
Submissions

Problem: K Radius Subarray Averages

med
30 min
Try to solve the K Radius Subarray Averages problem.

Statement

You are given a 00 indexed integer array nums of length n, and an integer k.

The kk radius average for a subarray centered at index i with radius k is the average of all elements in nums spanning from index i - k to i + k inclusive. If there are fewer than k elements before or after index i, then the kk radius average is −1-1.

Return an array avgs of length n where avgs[i] is the kk radius average for the subarray centered at index i.

Note: The average of xx elements is the sum of the xx elements divided by xx, using integer division which rounds down to the nearest integer.

Constraints:

  • n == nums.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq nums[i], k ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: K Radius Subarray Averages

med
30 min
Try to solve the K Radius Subarray Averages problem.

Statement

You are given a 00 indexed integer array nums of length n, and an integer k.

The kk radius average for a subarray centered at index i with radius k is the average of all elements in nums spanning from index i - k to i + k inclusive. If there are fewer than k elements before or after index i, then the kk radius average is −1-1.

Return an array avgs of length n where avgs[i] is the kk radius average for the subarray centered at index i.

Note: The average of xx elements is the sum of the xx elements divided by xx, using integer division which rounds down to the nearest integer.

Constraints:

  • n == nums.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 0≤0 \leq nums[i], k ≤105\leq 10^5