180. Deque Operations
A DEQUE — a double-ended queue — allows adding and removing at BOTH ends, all in constant time.
That makes it a queue and a stack at once, and it is exactly what a sliding-window problem needs later in this topic.
Print Empty for any read or removal on an empty deque, and carry on.
Constraints - `1 ≤ q ≤ 200000` - `-1000000 ≤ x ≤ 1000000`
Input
The first line contains an integer q, the number of operations.
Each of the next q lines is one operation:
- 1 x — add x at the FRONT
- 2 x — add x at the BACK
- 3 — remove the front value and print it
- 4 — remove the back value and print it
- 5 — print the front value without removing it
- 6 — print the back value without removing it
Output
Print one line for each operation from 3 to 6 — the value, or Empty.
Operations 1 and 2 print nothing.