Minimum Average Difference 
IntuitionApproachComplexity
Time complexity:
O(n)
Space complexity:
O(1)Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(n)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)
# Code
```cpp []
class Solution {
public:
    int minimumAverageDifference(vector<int>& nums) {
        int n = nums.size();
        if (n == 1)
            return 0; // handle the edge case
        long long totalSum = 0, currentSum = 0;
        for (int i : nums) {
            totalSum += i; // stored total sum in a variable
        }
        int difference = INT_MAX;
        int ans = -1; // initially give any random value to the answer 
        for (int i = 0; i < n; i++) {
            currentSum += nums[i];
            long long left = currentSum / (i + 1);  // left average for every current sum (Or, you can say, for every i) 
            long long right =
                (i == n - 1) ? 0 : (totalSum - currentSum) / (n - i - 1);  // used ternary operator 

            int currentDifference = abs(left - right);
            if (currentDifference < difference) {
                difference = currentDifference;  // if the current difference is less than the previous one, change the value of previous to the current difference
                ans = i; //store the index to the answer as well 
            }
        }
        return ans;
    }
};
```
['Array', 'Prefix Sum', 'C++']