minimum-average-difference
\n\n# Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n\n
\n\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n        \n        long sum=0;\n        for(int x:nums) sum+=x;\n        int res=0;\n        long min=Long.MAX_VALUE;\n        long curr=0;\n        for(int i=0;i<nums.length-1;i++){\n            curr+=nums[i];\n            sum-=nums[i];\n            \n            long diff=Math.abs(curr/(i+1)-sum/(nums.length-i-1));\n            \n            if(diff<min){\n                min=diff;\n                res=i;\n            }\n        }\n        curr+=nums[nums.length-1];\n        if(curr/nums.length<min){\n            res=nums.length-1;\n        }\n        return res;\n        \n    }\n}\n\n\n```
['Java']