Sherlock and Array

  • + 0 comments

    Here is the solution in Py3

    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    # 
    #Complete the 'balancedSums' function below.
    #
    # The function is expected to return a STRING.
    # The function accepts INTEGER_ARRAY arr as parameter.
    #
    for t in range(int(input())):
        n = int(input())
        a = [int(b) for b in input().split()]
        s = sum(a)
        count = 0
        for i in range(n):
            if 2*count == s-a[i]:
                print("YES")
                break
            count += a[i]
        else:
            print("NO")