Python very easy detailed code. Use one queue to track moving elements (with image)
Idea is to use a queue to have left_sum and right_sum.\nAnd use a queue to track elements moving from right_sum to left_sum. Also update the length which is the
Idea is to use a queue to have left_sum and right_sum.\nAnd use a queue to track elements moving from right_sum to left_sum. Also update the length which is the divisor.\n\n**Note**: This can also be done without a queue and make space complexity to O(1). But using a queue makes it alot easier to write and understand. Time complexity remains the same.\n\nOnce an element is removed from left of the queue (which contains right part of array). \n1. Add it to left_sum\n2. Remove it from right_sum\n3. Add 1 to left_length\n4. Remove 1 from right_length\n\n![image](https://assets.leetcode.com/users/images/567bc13c-a84e-4c00-a455-0037ed13124b_1651341859.6866913.png)\n\n\n\n```\ndef minimumAverageDifference(self, nums: List[int]) -> int:\n    n = len(nums)\n    if n == 1:\n        return 0\n\n    queue = deque(nums[1: ])\n\n    left_sum = sum(nums[0: 1])\n    right_sum = sum(queue)\n\n    left_length = 1\n    right_length = n - 1\n\n    i = 0\n\n    min_avg = sys.maxsize\n    min_avg_idx = None\n\n    while i < n:\n        left_avg = left_sum // left_length\n        if right_length:\n            right_avg = right_sum // right_length\n        else:\n            right_avg = 0\n\n        diff = abs(left_avg - right_avg)\n        if diff < min_avg:\n            min_avg = diff\n            min_avg_idx = i\n\n        # if queue is empty, we can stop. as it is the end.\n        if not queue:\n            break\n\t\t# remove ele from left of the queue\n        element = queue.popleft()\n\n\t\t# update for next iteration\n        left_sum = left_sum + element\n        right_sum = right_sum - element\n\n        left_length += 1\n        right_length -= 1\n\n        i += 1\n\n    return min_avg_idx\n```
['Python']