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.
if(len(h1)==0 or len(h2)==0 or len(h3)==0):
return 0
elif(len(h1)==1 or len(h2)==1 or len(h3)==1):
if(h1[0]==h2[0] and h3[0]==h2[0]):
return h1[0]
else:
return 0
for i in range(-2,-len(h1)-1,-1):
h1[i]=h1[i]+h1[i+1]
for i in range(-2,-len(h2)-1,-1):
h2[i]=h2[i]+h2[i+1]
for i in range(-2,-len(h3)-1,-1):
h3[i]=h3[i]+h3[i+1]
while(h1[0]!=h2[0] or h1[0]!=h3[0]):
if(h1[0]>=h2[0] and h1[0]>=h3[0]):
h1.pop(0)
elif(h1[0]<=h2[0] and h2[0]>=h3[0]):
h2.pop(0)
else:
h3.pop(0)
if(not(h1) or not(h2) or not(h3)):
return 0
return h1[0]
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Equal Stacks
You are viewing a single comment's thread. Return to all comments →
SHRIYAANSH KE PAPA KA CODE
if(len(h1)==0 or len(h2)==0 or len(h3)==0): return 0 elif(len(h1)==1 or len(h2)==1 or len(h3)==1): if(h1[0]==h2[0] and h3[0]==h2[0]): return h1[0] else: return 0 for i in range(-2,-len(h1)-1,-1): h1[i]=h1[i]+h1[i+1] for i in range(-2,-len(h2)-1,-1): h2[i]=h2[i]+h2[i+1] for i in range(-2,-len(h3)-1,-1): h3[i]=h3[i]+h3[i+1]