Javascript O(n) solution
Intuition\n Describe your first thoughts on how to solve this problem. \nFor each calculation by index, we can separate nums into two sub-arrays: left-side and 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFor each calculation by index, we can separate `nums` into two sub-arrays: left-side and right-side. Making the sum of entire left and right sides is not needed, just substract from right and add to left.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUse two variables to save the sum of each side. At first, left side sum is 0 and right side sum is sum(nums). On each iteration i, add nums[i] to the left and substract nums[i] to the right, then calculate absolute average and update answer.\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar minimumAverageDifference = function(nums) {\n    let nL=nums.length;\n    let leftSum = 0;\n    let rightSum = nums.reduce((p,n)=>{return p+n},0);\n\n    let minimum = Infinity;\n    let ans = Infinity;\n    for (let i=0; i<nL; i++){\n        leftSum += nums[i];\n        rightSum -= nums[i];\n        let res = Math.abs(Math.floor(((leftSum)/(i+1))) - Math.floor(((rightSum)/Math.max(1,(nL-1-i)))));\n        if(res < minimum){\n            minimum = res;\n            ans = i;\n        }\n    }\n    return ans;\n};\n```
['JavaScript']