Python | Easy Solution | Lists | Prefix Sum
CODE 1 (BETTER)\n\nclass Solution:\n    def minimumAverageDifference(self, nums: List[int]) -> int:\n        first = [nums[0]]\n        second = nums[1:]\n\n   
# CODE 1 (BETTER)\n```\nclass Solution:\n    def minimumAverageDifference(self, nums: List[int]) -> int:\n        first = [nums[0]]\n        second = nums[1:]\n\n        if len(nums) == 1:\n            return 0\n\n        v1 = sum(first)\n        v2 = sum(second)\n        l1 = 1\n        l2 = len(nums) - 1\n\n        currDiff = abs((v1 // l1) - (v2 // l2))\n        currIndex = 0\n\n        for i in range(1, len(nums)-1):\n            if l1 == 0:\n                v1 = 0\n                l1 = 0\n            else:\n                v1 = (v1 + nums[i])\n                l1 += 1\n\n\n            if l2 == 0:\n                v2 = 0\n                l2 = 0\n            else:\n                v2 = (v2 - nums[i])\n                l2 -= 1\n\n\n            if currDiff > abs((v1 // l1) - (v2 // l2)):\n                currDiff = abs((v1 // l1) - (v2 // l2))\n                currIndex = i\n\n        v1 = sum(nums[:]) // len(nums[:])\n\n        if currDiff > abs(v1 - 0):\n                currDiff = abs(v1 - 0)\n                currIndex = len(nums)-1\n\n        return currIndex\n```\n# CODE 2 (LAZY)\n```\nclass Solution:\n    def minimumAverageDifference(self, nums: List[int]) -> int:\n        first = [nums[0]]\n        second = nums[1:]\n        if len(nums) == 1:\n            return 0\n        v1 = sum(first)\n        v2 = sum(second)\n        currDiff = abs((v1 // len(first)) - (v2 // len(second)))\n        currIndex = 0\n        for i in range(1, len(nums)-1):\n            first.append(nums[i])\n            second.pop(0)\n            # print(first, second)\n            if len(first) == 0:\n                v1 = 0\n                l1 = 0\n            else:\n                v1 = (v1 + nums[i])\n                l1 = len(first)\n            if len(second) == 0:\n                v2 = 0\n                l2 = 0\n            else:\n                v2 = (v2 - nums[i])\n                l2 = len(second)\n            # print(v1, v2)\n            if currDiff > abs((v1 // l1) - (v2 // l2)):\n\n                currDiff = abs((v1 // l1) - (v2 // l2))\n                currIndex = i\n        v1 = sum(nums[:]) // len(nums[:])\n        if currDiff > abs(v1 - 0):\n                currDiff = abs(v1 - 0)\n                currIndex = len(nums)-1\n        return currIndex\n```
['Array', 'Prefix Sum', 'Python3']