Deque Commands With Errors

Programming Interview Hard 5 views
Back to Questions

Problem Description

You will receive q commands: PUSHFRONT x, PUSHBACK x, POPFRONT, POPBACK. Start empty. On POP when empty, output ERROR and stop. Else after all commands output final deque as space-separated or EMPTY.

Input Format

First line q. Next q lines commands.

Output Format

One line result or ERROR.

Sample Test Case

Input:
6 PUSHBACK 1 PUSHFRONT 2 POPBACK POPFRONT PUSHBACK 5 POPFRONT
Output:
ERROR

Constraints

q

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next