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.
Only 2 test cases (0,4)are passing all other are failing , can't think where is it going wrong
public static int solve(Stack f,Stack s,int len , int cs,int max){
int n = f.peek()>=s.peek()?s.peek():f.peek();
// System.out.println(f.peek());
// System.out.println(s.peek());
// System.out.println("n:"+n);
if(cs+n a, List b) {
// Write your code here
Stack first = new Stack<>();
for(int i =a.size()-1;i>=0;i--){
first.push(a.get(i));
}
// System.out.println;
Stack<Integer> Second = new Stack<>();
for(int i =b.size()-1;i>=0;i--){
Second.push(b.get(i));
}
int len = 0;
int currsumm = 0;
return solve(first,Second,len,currsumm,maxSum);
}
}
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 →
Only 2 test cases (0,4)are passing all other are failing , can't think where is it going wrong public static int solve(Stack f,Stack s,int len , int cs,int max){ int n = f.peek()>=s.peek()?s.peek():f.peek(); // System.out.println(f.peek()); // System.out.println(s.peek()); // System.out.println("n:"+n); if(cs+n a, List b) { // Write your code here Stack first = new Stack<>(); for(int i =a.size()-1;i>=0;i--){ first.push(a.get(i)); } // System.out.println;
}