← Applied intuition Interview Insights

Applied intuition·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Applied Intuition had me implement a circular buffer from scratch, which sounds like a classic warm-up until you realize they want the full thing: template types, fixed capacity, overwrite-on-full semantics, and a real conversation about index management. Pretty deep for what felt like a phone screen.

Questions Asked (1)

Q1

Implement a generic CircularBuffer<T, N> class in C++ with push, pop, and print methods. The buffer should have a fixed capacity set at instantiation, use pre-allocated storage, and overwrite the oldest element when full. Walk through how you manage head and tail indices, handle wrap-around, and distinguish between a full and empty buffer.

Algorithms & Data StructuresTechnical Trade-offsSystem Design
Author's notes

I knew the general idea of a circular buffer but fumbled the full-vs-empty distinction under pressure.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then outline the design choices (e.g., head/tail indices, full/empty handling) before writing code. Walk through the implementation step-by-step, explaining how you manage indices and wrap-around, and discuss trade-offs and edge cases.

Pro tip: Mention that you would use a power-of-two capacity to replace modulo with bitwise AND for efficiency, and discuss how to make the buffer thread-safe if needed.

1. Clarify Requirements and Constraints

Confirm the expected behavior: fixed capacity, overwrite oldest when full, and methods push, pop, print. Ask about thread safety, exception safety, and whether pop should return a value or be void.

2. Design the Data Structure

Choose between using head and tail indices with a count, or a sentinel to distinguish full/empty. Explain how pre-allocated storage (e.g., std::array or raw buffer) will be used.

3. Implement Index Management and Wrap-Around

Describe how head points to the oldest element and tail to the next write position. Use modulo arithmetic (or bitwise AND for power-of-two sizes) to wrap indices.

4. Handle Full and Empty Conditions

Explain how to detect full (e.g., count == N) and empty (count == 0) states. If overwriting, when full, advance head before writing to tail.

5. Discuss Trade-offs and Edge Cases

Cover trade-offs: using a count vs. sentinel, modulo vs. bitwise AND, and thread safety. Mention edge cases like popping from empty, pushing when full, and printing order.

Key Points to Mention

  • Use of head and tail indices with a count variable to distinguish full/empty.
  • Wrap-around implementation using modulo or bitwise AND for power-of-two capacities.
  • Overwrite policy: when full, advance head before writing to tail.
  • Pre-allocated storage: std::array<T, N> or raw buffer with placement new.
  • Thread safety considerations: mutex or lock-free with atomics.
  • Exception safety: ensure no leaks and strong guarantee if T's constructor throws.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.