Tap here to switch tabs
Problem
Submissions

Problem: Minimum Average Difference

med
30 min
Try to solve the Minimum Average Difference problem.

Statement

You are given a 00 indexed integer array nums of length n.

The average difference at index i is the absolute difference between the average of the first i+1i + 1 elements of nums and the average of the last n−i−1n - i - 1 elements of nums. Both averages must be rounded down to the nearest integer.

Return the index with the minimum average difference. If there are multiple indices with the same minimum average difference, return the smallest index.

Note:

  • The average of kk elements is the sum of the kk elements divided by kk, rounded down to the nearest integer using integer division.

  • The average of 00 elements is considered to be 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Average Difference

med
30 min
Try to solve the Minimum Average Difference problem.

Statement

You are given a 00 indexed integer array nums of length n.

The average difference at index i is the absolute difference between the average of the first i+1i + 1 elements of nums and the average of the last n−i−1n - i - 1 elements of nums. Both averages must be rounded down to the nearest integer.

Return the index with the minimum average difference. If there are multiple indices with the same minimum average difference, return the smallest index.

Note:

  • The average of kk elements is the sum of the kk elements divided by kk, rounded down to the nearest integer using integer division.

  • The average of 00 elements is considered to be 00.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

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