Preparing your design workspace

Loading the problem and your saved attempt…

Design a Dynamic Phonebook with Autocomplete

Model contacts and prefix autocomplete that reflects every completed add, edit, or delete.

Design the low-level object model and interfaces for a Dynamic Phonebook with Autocomplete.

For this exercise, assume a contact has an immutable ID, display name, and one or more phone numbers. Add, update, and delete are authoritative; autocomplete(prefix,limit) requires 1 <= limit <= 10, compares names under one declared normalization policy, and orders results by normalized name then ID.

A completed mutation must be visible to the next autocomplete read. The candidate may store normalized keys or compute them behind a policy boundary.

For invalid states, return explicit outcomes for: duplicate ContactId; unknown or deleted ContactId; invalid phone number; autocomplete limit outside 1 through 10.

Preserve this invariant: A completed contact mutation is visible to the next autocomplete read: authoritative contact state and searchable keys advance atomically, or the read path merges a committed pending-key delta while filtering stale ContactId/version entries.