Queue With Two Stacks

Programming Interview Medium 8 views
Back to Questions

Problem Description

You will receive q commands: ENQ x, DEQ, FRONT. Create Queue class using two stacks. FRONT prints front value or EMPTY.

Input Format

First line q. Next q lines commands.

Output Format

Outputs for FRONT.

Sample Test Case

Input:
7 ENQ 5 ENQ 2 FRONT DEQ FRONT DEQ FRONT
Output:
5 2 EMPTY

Constraints

q

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next