PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of fixed-capacity circular queue data structures, array-based indexing, modular arithmetic, and the requirement for constant-time (O(1)) enqueue/dequeue operations.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Design a fixed-capacity circular queue

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Design a fixed-capacity circular queue that supports enqueue(x), dequeue(), front(), rear(), isEmpty(), and isFull() operations in O( 1) time. Implement it using an array and modular arithmetic. Explain how you manage head and tail indices, how you distinguish between empty and full states, and provide the time and space complexity.

Quick Answer: This question evaluates understanding of fixed-capacity circular queue data structures, array-based indexing, modular arithmetic, and the requirement for constant-time (O(1)) enqueue/dequeue operations.

Simulate enqueue, dequeue, front, rear, isEmpty, and isFull operations on a circular queue.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: (3, [['enqueue',1], ['enqueue',2], ['rear'], ['dequeue'], ['front'], ['isFull']])

Expected Output: [True, True, 2, True, 2, False]

Explanation: Basic queue operations.

Input: (1, [['isEmpty'], ['enqueue',5], ['enqueue',6], ['isFull'], ['rear']])

Expected Output: [True, True, False, True, 5]

Explanation: Full queue.

Input: (2, [['dequeue'], ['front']])

Expected Output: [False, None]

Explanation: Empty queue.

Hints

  1. Choose a representation that makes the requested operation direct.
  2. Handle empty inputs and boundary cases first.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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.

Related Coding Questions

  • Implement Top-p (Nucleus) Sampling in NumPy - Amazon (medium)
  • Implement Multi-Head Attention from Scratch in NumPy - Amazon (medium)
  • Detect and Break a Cycle in a Singly Linked List - Amazon (medium)
  • Caesar Cipher with Translation-Table Optimization - Amazon (medium)
  • Minimum Drone Delivery Time on a Ring of Hubs - Amazon (medium)