You are viewing a single comment's thread. Return to all comments →
In python, sum(n) function has O(n) time. Because each loop time, you calculate again "left list" and "rigth list", so I can say that your program has O(n^2) time.
To solve this, you should calculate sum_left and sum_right at 0 position outsite your loop, then each loop time, you to do:
sum_left += arr[i-1]
sum_right -= arr[i]
Then compare sum_left and sum_right. With solution, your program will only take O(n) time