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.
publicstaticinttwoStacks(intmaxSum,List<Integer>a,List<Integer>b){// Write your code herereturntwoStacks(maxSum,a,b,0,0)-1;}publicstaticinttwoStacks(intmaxSum,List<Integer>a,List<Integer>b,intsum,intcount){if(sum>maxSum){returncount;}if(a.isEmpty()||b.isEmpty()){returncount;}intans1=twoStacks(maxSum,a.subList(1,a.size()),b,sum+a.get(0),count+1);intans2=twoStacks(maxSum,a,b.subList(1,b.size()),sum+b.get(0),count+1);intmax=Math.max(ans1,ans2);returnmax;}}
Game of Two Stacks
You are viewing a single comment's thread. Return to all comments →
What is the problem in this code????