luoheng
9/4/2019 - 3:12 AM

PassingCars

# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")

def solution(A):
    # write your code in Python 3.6
    num, Sum = 0, 0
    for a in A:
        if a == 1:
            Sum += num
        elif a == 0:
            num += 1
    return Sum if Sum <= 1000000000 else -1