the given example is giving the correct output but all test cases are displaying wrong ans
#include
#include
using namespace std;
int main () {
int n;
cin>>n;
stack q;
for(int i=0;i<n;i++)
{
int b,c;
cin>>b;
if(b==2)
{
cin>>c;
q.push©;
}
else
{
if(q.empty())
cout<<“No Code”;
else
{
cout<<q.top()<<endl;
q.pop();
}
}
}
return 0;
}
Please see the 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.