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
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.