Design Circular Deque
medium
Design your implementation of the circular double-ended queue (deque). Your implementation should support following operations: 1. MyCircularDeque(): Initializes the deque object. 2. insertFront(): Adds an item at the front of Deque. 3. insertLast(): Adds an item at the rear of Deque. 4. deleteFront(): Deletes the front item from the Deque and return it's value. If the deque is empty, return null. 5. deleteLast(): Deletes the last item from Deque and return it's value. If the deque is empty, return null. 6. getFront(): Gets the front item from the Deque. If the deque is empty, return null. 7. getRear(): Gets the last item from Deque. If the deque is empty, return null. 8. isEmpty(): Checks whether Deque is empty or not.
Constraints
None
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
insertLast 1
insertLast 2
insertFront 3
insertFront 4
getRear
deleteLast
getRear
deleteLast
insertFront 4
getFront
Sample Output
2
2
1
1
4