Solution in java with time complexity : O(N) and Space O(1)
Intuition\n \n\n# Approach\n Runing sum  \n\n# Complexity\n- Time complexity:\n O(N) \n\n- Space complexity:\n O(1) \n\n# Code\n\nclass Solution {\n    public i
# Intuition\n<!-- -->\n\n# Approach\n<!-- Runing sum  -->\n\n# Complexity\n- Time complexity:\n<!-- O(N) -->\n\n- Space complexity:\n<!-- O(1) -->\n\n# Code\n```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n\n        long min=Long.MAX_VALUE;\n\n        long sum = 0L;\n\n        for(int y : nums) sum+=y;\n\n        int x=0;\n        long currSum=0;\n        int ans=0;\n        int y=0;\n        if(sum==0) return 0;\n\n\n        for(; y<nums.length-1 ; y++){\n            x++;\n            currSum+=nums[y];\n            sum-=nums[y];\n            long avg=Math.abs(((long)currSum/x) - ((long)sum/(nums.length-x)));\n            if(min > avg ){\n                min=avg;\n                ans=y;\n            }\n        }\n        currSum+=sum;\n        sum=0;\n\n        if(min>currSum/nums.length) ans=y;\n\n\n\n        return ans;\n        \n    }\n}\n```
['Prefix Sum', 'Java']