We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
what is the problem in this code it passed all test cases except 2 showing time limit exceeded can someone help
def balancedSums(arr):
# Write your code here
if len(arr)==1:
return 'YES'
else:
a='NO'
for i in range(len(arr)):
left_sum=sum(arr[:i])
right_sum=sum(arr[i+1:])
if left_sum==right_sum:
a='YES'
break
return a
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Array
You are viewing a single comment's thread. Return to all comments →
what is the problem in this code it passed all test cases except 2 showing time limit exceeded can someone help def balancedSums(arr): # Write your code here if len(arr)==1: return 'YES' else: a='NO' for i in range(len(arr)): left_sum=sum(arr[:i]) right_sum=sum(arr[i+1:]) if left_sum==right_sum: a='YES' break return a