Design generic stack and queue data structures with proper encapsulation. Include features for push, pop, peek, size tracking, and iteration support.
Suggested time: 45 minutes
Loading the workspace...
Stack and Queue seem like textbook data structures with trivial implementations. But designing them as production-quality, thread-safe, generic collections surfaces real engineering decisions: linked list vs. array backing, O(1) guarantees vs. cache locality, lock-based vs. lock-free concurrency, and how to expose traversal without leaking internal structure. The design challenge is building two structures that share a common interface while having fundamentally different access patterns.
Stack (LIFO)
Queue (FIFO)
Size and Empty Check
Generic Element Types
Design a Deck of Cards (easy)
Design a Parking Lot (easy)
Design a Logger System (easy)
Design a Shape Calculator (easy)
Design a Vending Machine (easy)
Design a Coffee Machine (easy)