Implement Stack using Array
Easy
Stacks
Stack
Design
Implement push, pop, top, isEmpty operations. Process commands and output results.
Constraints
Commands ≤ 1000
Examples
Example 1:
Input: push 1
push 2
top
pop
top
Output: 2
2
1
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console