Medium
,Array
,Prefix Sum
2256. Minimum Average Difference
You are given a 0-indexed integer array nums
of length n
.
The average difference of the index i
is the absolute difference between the average of the first i + 1
elements of nums
and the average of the last n - i - 1
elements. Both averages should be rounded down to the nearest integer.
Return the index with the minimum average difference. If there are multiple such indices, return the smallest one.
Note:
n
elements is the sum of the n
elements divided (integer division) by n
.0
elements is considered to be 0
.Example 1:
Example 2:
Constraints:
nums.length
<= 105nums[i]
<= 105玉山 Dec 5, 2022
Marsgoat Dec 5, 2022