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.
defequalStacks(h1,h2,h3):# Write your code heresum1=sum(h1)sum2=sum(h2)sum3=sum(h3)ifsum1==sum2==sum3:returnsum1else:index1,index2,index3=0,0,0whilenotsum1==sum2==sum3:ifsum1>sum2orsum1>sum3:sum1-=h1[index1]index1+=1elifsum2>sum1orsum2>sum3:sum2-=h2[index2]index2+=1elifsum3>sum1orsum3>sum2:sum3-=h3[index3]index3+=1ifindex1==len(h1)orindex2==len(h2)orindex3==len(h3):return0else:returnsum1
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
Python