Sample case passed not other case

please look at my code and check why test cases are not getting passed?
#include<bits/stdc++.h>
using namespace std;

int main () {
int t;
cin>>t;
int type,cost;
stack s;
while(t–){
cin>>type;
if(type==2){
cin>>cost;
s.push(cost);
}
if(type==1){
if(!s.empty()){
cout<<s.top()<<"\n";
s.pop();
}
if(s.empty()){
continue;
}
continue;
}
}
return 0;
}

Hi @aman.tandon3096
In your code you have forgot to add a case when stack is empty and query is of type 1 , then you have to print No Code.
Here is your corrected code :

Hi @aman.tandon3096
Mark your doubt as resolved if you get what was wrong with your code.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.