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.
No need to sum(arr) at all, that would cause another uneccesary O(n), here's my code:
defsolve(a,size):# Complete this functiondifference=0left_index=0compare_count=size-1foriinxrange(size+1):ifdifference>0:difference-=a[compare_count+left_index-i]else:difference+=a[left_index]left_index+=1return'YES'ifdifference==0else'NO'
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 →
No need to sum(arr) at all, that would cause another uneccesary O(n), here's my code: