stack erase 1

stack erase

stack stk;
stk.push(5);
int ans = stk.top(5); // ans =5
stk.pop();//removes 5

Here is what the above code is Doing:
1. We create a stack called stk.
2. We push 5 onto the stack.
3. We assign the top element of the stack to the variable ans.
4. We pop the top element off the stack.

Similar Posts