Implement a Fixed-Capacity Deque
Company: Applied
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency with double-ended queue semantics, fixed-capacity data structure design, constant-time (O(1)) operations, and correct handling of boundary conditions and wraparound.
Constraints
- Inputs are provided as Python literals matching the function signature.
- Return a deterministic exact-match result.
Examples
Input: (3, [['insertLast',1], ['insertLast',2], ['insertFront',3], ['insertFront',4], ['getRear'], ['isFull'], ['deleteLast'], ['insertFront',4], ['getFront']])
Expected Output: [True, True, True, False, 2, True, True, True, 4]
Explanation: Wraparound and full insert.
Input: (1, [['isEmpty'], ['deleteFront'], ['insertFront',9], ['getRear']])
Expected Output: [True, False, True, 9]
Explanation: Empty and singleton.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.