Time Complexity of the program O(n).

if the middle value is q and the sum is p then we can write the equation as follow

- p + q + p = sum [as the left and the right sum are same]
- 2p = sum - q

According to that Mathematical Logic The code can be written as follow:

```
def balancedSums(arr):
# Write your code here
left_sum = 0
arr_sum = sum(arr)
for i in arr:
if (2 * left_sum) == arr_sum - i:
return "YES"
left_sum += i
return "NO"
```

## Top comments (0)