🎉 One-stop destination for all your technical interview Preparation 🎉
Insert function.
reverse function.
void inserT(stack<int> &s, int ele)
{
if (s.empty())
{
s.push(ele);
return;
}
int temp = s.top();
s.pop();
inserT(s, ele);
s.push(temp);
}
void reverse(stack<int> &s)
{
if (s.size() == 1)
return;
int temp = s.top();
s.pop();
reverse(s);
inserT(s, temp);
}