How can I write a program to implement a Stack using Array for this example:
Example:
Input: push(2) push(3) pop() push(4) pop() Output: 3, 4 Explanation: push(2) the stack will be {2} push(3) the stack will be {2 3} pop() poped element will be 3, the stack will be {2} push(4) the stack will be {2 4} pop() poped element will be 4
I need suggestions for this. Thank you!
Referenece: https://www.scaler.com/topics/stack-class-in-java/