[Java] ✅ Runtime: 12ms, faster than 100.00% | O(N) time, O(1) space🔥🔥🔥
java\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        int n = nums.length;\n\t\t\n\t\tlong sum = 0;\n        for(int num : nums
```java\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        int n = nums.length;\n\t\t\n\t\tlong sum = 0;\n        for(int num : nums) sum += num;\n\t\t\n        long minDiff = Integer.MAX_VALUE;\n\t\tlong leftSum = 0; long rightSum = sum;\n        int ans = 0;\n        \n        for (int i = 0; i < n; i++) {\n            leftSum += nums[i];\n            rightSum -= nums[i];\n            long lAvg = leftSum/(i+1);\n            long rAvg = (n-1-i) != 0 ? rightSum/(n-1-i) : rightSum;\n            long diff = Math.abs(lAvg - rAvg);\n            if (diff == 0) return i;\n            if (diff < minDiff) {\n                minDiff = diff;\n                ans = i;\n            }\n        }\n        \n        return ans;\n    }\n}\n```
['Java']