← Ziphq Interview Insights

Ziphq·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Ziphq software engineer round focused entirely on an OOD coding problem. You get starter code and have to build out a vending machine from scratch, including writing your own tests, which I was not expecting.

Questions Asked (1)

Q1

Design and implement a vending machine in an object-oriented style. You need to define the core types (products, inventory slots), handle money insertion to build up a balance, and implement change-making when a purchase completes. Starter code is provided; you are also expected to write your own tests.

System DesignTechnical Trade-offsData Modeling
Author's notes

The starter code felt like a gift until I realized it was also a constraint.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then sketch the core object model (Product, InventorySlot, VendingMachine) and state transitions for money handling and dispensing. Implement incrementally with tests for each behavior, and discuss trade-offs like change-making strategy and extensibility.

Pro tip: Treat the vending machine as a state machine and explicitly model states (Idle, HasBalance, Dispensing, ReturningChange) to simplify logic and make edge cases obvious. Also, mention that you'd use a greedy algorithm for change-making but note its limitations and consider dynamic programming if coin denominations are non-canonical.

1. Clarify Requirements and Constraints

Ask about accepted coin denominations, product types, inventory limits, change availability, and whether the machine supports multiple items per purchase. Confirm expected behaviors for edge cases like insufficient funds or out-of-stock items.

2. Design Core Object Model

Define classes: Product (name, price), InventorySlot (product, quantity), VendingMachine (inventory, balance, coin inventory). Consider using interfaces for payment methods and inventory management to allow future extensions.

3. Implement Money Handling and Purchase Flow

Implement methods to insert money (updating balance), select product (checking stock and funds), dispense product, and return change. Use a state machine or clear conditional logic to manage transitions between idle, accumulating balance, and dispensing states.

4. Implement Change-Making Algorithm

Choose a change-making strategy (e.g., greedy for standard denominations, dynamic programming for optimality). Ensure the machine tracks available coins for change and handles cases where exact change cannot be made.

5. Write Tests and Discuss Trade-offs

Write unit tests covering successful purchase, insufficient funds, out-of-stock, exact change, and change-making failures. Discuss trade-offs: simplicity vs. extensibility, greedy vs. optimal change-making, and how design choices impact maintainability.

Key Points to Mention

  • Encapsulation of product and inventory data with clear responsibilities for each class.
  • State management for the vending machine (e.g., idle, has balance, dispensing) to handle transitions cleanly.
  • Change-making algorithm choice and its implications (greedy vs. dynamic programming, coin availability).
  • Error handling for edge cases: insufficient funds, out-of-stock, unable to make change.
  • Testability: designing classes with dependency injection and writing comprehensive unit tests.
  • Extensibility: how to add new payment methods, product types, or pricing strategies without major refactoring.

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