Sherlock and Array

  • + 0 comments
    def balancedSums(arr):
        # Write your code here
        left = 0
        right = sum(arr)
        for i in range(len(arr)):
            if i != 0:
                left += arr[i-1]
            right -= arr[i]
            if left == right:
                return 'YES'
        return 'NO'