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.
Here is my golang solution. It doesn't work (lol). Can anyone point out my logic problem?
functwoStacks(maxSumint32,a[]int32,b[]int32)int32{// Write your code herevaransint32varposAint32varposBint32for(len(a)>0||len(b)>0)&&maxSum>=0{iflen(a)>0{posA=a[0]}iflen(b)>0{posB=b[0]}ifposA<=posB{maxSum=maxSum-posAa=a[1:]}else{maxSum=maxSum-posBb=b[1:]}ifmaxSum>=0{ans++}}returnans}
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 →
Here is my golang solution. It doesn't work (lol). Can anyone point out my logic problem?