https://ide.codingblocks.com/s/62026
In this question, I am getting TLE for first two testcases.
Stack : Prateek Sir and Coding
Hey hardik, In given test cases “2 73” is not a string, these are two integers. and what if instead of 73 there is a 3 digit value. so take inpur 2 numbers and not a string.
But that will be a problem because at some cases there is only one input and some there are two.
first input the type of query… then apply condition if(query == 2) then input another number
else print required output
please help
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int t,a,b;
cin>>t;
stack s;
for(int i=0;i<t;i++)
{
cin>>a;
if(a==2)
{
cin>>b;
s.push(b);
}
else
{
cout<<s.top()<<'\n';
s.pop();
}
if(s.empty())
cout<<"No Code"<<'\n';
}
}
im getting a run- error for this solution