Find the index of the element with maximum absolute deviation
Note that in Python 3, you don't need * 1.0 to get floating-point division.  On the other hand, in Python 2, range(len(A)) would use O(N) space.

I recommend three changes:


Put the special case first, to reduce the separation between return -1 and the reason for returning -1.
Rename max_avg → max_deviation.
Use enumerate() to iterate over the array.


The revised solution would be:

def solution(A):
    if not A:
        return -1
    average = sum(A) * 1.0 / len(A)
    max_deviation = 0
    pos = 0
    for i, a in enumerate(A):
        if abs(a - average) &gt; max_deviation:
            max_deviation = abs(a - average)
            pos = i
    return pos