using java
class Solution {\n    public int minimumAverageDifference(int[] nums) {\n\tint len = nums.length, res = 0;\n\tlong min = Integer.MAX_VALUE, sum = 0, leftSum = 0
class Solution {\n    public int minimumAverageDifference(int[] nums) {\n\tint len = nums.length, res = 0;\n\tlong min = Integer.MAX_VALUE, sum = 0, leftSum = 0, rightSum = 0;\n\tfor (int num : nums)\n\t\tsum += num;\n\tfor (int i = 0; i < len; i++) {\n\t\tleftSum += nums[i];\n\t\trightSum = sum - leftSum;\n\t\tlong diff = Math.abs(leftSum / (i + 1) - (len - i == 1 ? 0 : rightSum / (len -i - 1)));\n\t\tif (diff < min) {\n\t\t\tmin = diff;\n\t\t\tres = i;\n\t\t}\n\t}\n\treturn res;\n}\n}
[]