[Java] Easy Solution || Using Prefix sum || O(n)
\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        long prefix[] =  new long[nums.length];\n        long sum = 0;\n        \n\t\
```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        long prefix[] =  new long[nums.length];\n        long sum = 0;\n        \n\t\tfor(int i = 0 ; i < nums.length ; i++) {\n\t\t\tprefix[i] = (i == 0)? nums[i] :  prefix[i -1] + nums[i];\n            sum += nums[i];\n\t\t}\n        long avgDiff = 0, minAvgDiff = Long.MAX_VALUE;\n        int idx = -1;\n\t\tfor(int i = 0 ; i < nums.length ; i++){\n            long post = (i == nums.length - 1)? 0 :((sum - prefix[i]) / (nums.length - i - 1));\n            avgDiff = Math.abs((prefix[i] / (i + 1)) - post);\n            if(avgDiff < minAvgDiff){\n                minAvgDiff = avgDiff;\n                idx = i;\n            }\n        }\n        return idx;\n    }\n}\n```\n\n**Upvote Please**
['Java']