Sherlock and Array

  • + 0 comments
    from functools import reduce
    
    def balancedSums(arr):
        sum_arr = sum(arr)
        return 'YES' if (reduce(lambda a, b: a + (b if a <= sum_arr // 2 else 0), arr) == reduce(lambda a, b: a + (b if a <= sum_arr // 2 else 0), reversed(arr))) else 'NO'