Wrong answer even if its going well for the test case in example

public static void Calculate(StacksUsingArrays stack, int q) throws Exception {

   //Write Your Code Here
   /* Donot initialize another Scanner use the static scanner already declared*/
   for(int i =0;i<q;i++){
	   int a = s.nextInt();
	   if(a == 2){
		   int b = s.nextInt();
		   stack.push(b);
	   }else if(a==1){
		   if(stack.isEmpty()){
			   continue;
		   }else{
			   System.out.println(stack.pop());
		  }
		   
	   }
   }
}

Please see where I went wrong also what will happen if stack is empty and we encounter 1 like first input is 1

@Vishu_1801 lemme check buddy!

@Vishu_1801 buddy a very small mistake. See this line!
If the pile is empty, print “No Code”

I have corrected ya code now you could try and run your code on any custom input you want, the case you are talking about will be clear to you now!


Bro as your query is clear, so it is mandatory you close the doubt by marking it resolved!
Happy coding!