Straightforward and Detailed Solution O(n)
Approach\n Describe your approach to solving the problem. \nCreate a prefix sum array. Then iterate through the prefix sum array  to obtain the averages. Then w
# Approach\n<!-- Describe your approach to solving the problem. -->\nCreate a prefix sum array. Then iterate through the prefix sum array  to obtain the averages. Then we simply check if this average is the minAvg so far. I have outlined an equation which can be used to solve this.\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```\nclass Solution:\n    def minimumAverageDifference(self, nums: List[int]) -> int:\n        \n        # pesudo code:\n\n        # prefix sum array\n        # [2, 7, 10, 19, 24, 27]\n\n        # n = 6\n        # i = 0\n        # equation: |(num[i] // i+1) - (nums[n-1] - nums[i] / n - i + 1)|\n        # |2 -  ((27 - 2) / 5)|\n        # |2 - 5| \n        # 3\n\n        # (7 // 2) \n\n        n = len(nums)\n        prefix = [nums[0]]\n        minDiff = float("inf")\n        idx = 0\n\n        # compute the prefix sum of the array\n        for i in range(1, n):\n            prefix.append(prefix[-1] + nums[i])\n        \n        # find the min difference average\n        for i in range(n):\n            \n            first = prefix[i] // (i+1)\n            second = 0\n\n            if (n - i - 1) > 0:\n                second = (prefix[n-1] - prefix[i]) // (n - i - 1)\n\n            avg = abs(first - second)\n            \n            if avg < minDiff:\n                idx = i\n                minDiff = avg\n            \n        return idx\n\n```
['Math', 'Prefix Sum', 'Python3']