PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Tml

Implement a Resizable Deque

Last updated: May 11, 2026

Quick Overview

This question evaluates proficiency in data structures and array-based implementations, specifically building a resizable double-ended queue (deque) backed by a circular array and understanding amortized O(1) operation costs.

  • medium
  • Tml
  • Coding & Algorithms
  • Software Engineer

Implement a Resizable Deque

Company: Tml

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Implement a double-ended queue (deque) data structure backed by a circular array. Your deque should support insertion and removal from both ends and should automatically resize when it becomes full. Required operations: - `pushFront(value)`: Insert `value` at the front. - `pushBack(value)`: Insert `value` at the back. - `popFront()`: Remove and return the front element. If the deque is empty, handle the error clearly. - `popBack()`: Remove and return the back element. If the deque is empty, handle the error clearly. - `peekFront()`: Return the front element without removing it. - `peekBack()`: Return the back element without removing it. - `isEmpty()`: Return whether the deque is empty. - `size()`: Return the number of elements currently stored. Implementation requirements: - Use an array as the underlying storage. - Treat the array as circular so that operations at both ends are efficient. - When the array is full, allocate a larger array, copy the elements in logical deque order, and update internal pointers correctly. - Each operation should run in `O(1)` amortized time.

Quick Answer: This question evaluates proficiency in data structures and array-based implementations, specifically building a resizable double-ended queue (deque) backed by a circular array and understanding amortized O(1) operation costs.

Tml logo
Tml
Apr 22, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

Implement a double-ended queue (deque) data structure backed by a circular array.

Your deque should support insertion and removal from both ends and should automatically resize when it becomes full.

Required operations:

  • pushFront(value) : Insert value at the front.
  • pushBack(value) : Insert value at the back.
  • popFront() : Remove and return the front element. If the deque is empty, handle the error clearly.
  • popBack() : Remove and return the back element. If the deque is empty, handle the error clearly.
  • peekFront() : Return the front element without removing it.
  • peekBack() : Return the back element without removing it.
  • isEmpty() : Return whether the deque is empty.
  • size() : Return the number of elements currently stored.

Implementation requirements:

  • Use an array as the underlying storage.
  • Treat the array as circular so that operations at both ends are efficient.
  • When the array is full, allocate a larger array, copy the elements in logical deque order, and update internal pointers correctly.
  • Each operation should run in O(1) amortized time.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Tml•More Software Engineer•Tml Software Engineer•Tml Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.