JAVA one loop Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minimumAverageDifference(int[] nums) {\n\n        double[] prefix = new double[nums.length + 1]; \n        for (int i=0;i<nums.length;i++){\n            prefix[i + 1] = prefix[i] + nums[i];\n        }\n        int bestIndex = 0;\n        int best = Integer.MAX_VALUE;\n        for (int i=0;i<nums.length;i++){\n            int prefixAverage = (int) Math.floor(prefix[i + 1] / (i + 1));\n            int suffixAverage = (int) Math.floor((prefix[nums.length]-prefix[i + 1])/(nums.length-i-1));\n            int averageDifference = Math.abs(prefixAverage - suffixAverage);\n            if (averageDifference < best) {\n                best = averageDifference;\n                bestIndex = i;\n            }\n        }\n        return bestIndex;\n    }\n}\n```
['Java']