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.
deftwoStacks(maxSum,a,b):# Write your code herei=j=s=0whilei<len(a)ands+a[i]<=maxSum:s+=a[i]i+=1n=maxn=ii-=1whilej<len(b):ifs+b[j]<=maxSum:s+=b[j]j+=1n+=1maxn=max(maxn,n)elifi>=0:s-=a[i]i-=1n-=1else:breakreturnmaxn
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Two Stacks
You are viewing a single comment's thread. Return to all comments →