Started with a hash map keyed by id, which felt obvious, and they nodded along.
Start by clarifying requirements and constraints, then propose a primary data structure (e.g., a hash map keyed by id) and discuss secondary indexes for name and email lookups. Address error handling for missing ids and duplicate emails, and consider trade-offs like memory vs. speed and consistency across indexes.
Pro tip: Mention that email uniqueness should be enforced at the data structure level (e.g., a separate set or map) to avoid race conditions, and discuss whether email updates should be atomic across indexes. Also, consider case sensitivity and normalization for emails.
Ask about expected operations, performance needs, concurrency, and whether name/email lookups are required. Confirm that id is immutable and unique, and email must be unique.
Use a hash map (or dictionary) for id-to-Employee mapping. For name and email lookups, consider secondary indexes: a multimap for name (since names may not be unique) and a map for email (since email is unique).
For get by id, return the employee or throw/return an error if not found. For update email, check if the new email is already taken (return error if so), then update both the employee object and the email index. For delete, remove from all indexes.
Weigh memory overhead of secondary indexes vs. lookup speed. Consider thread safety, case sensitivity for emails, and whether to allow duplicate names. Discuss how to handle id not found (e.g., return null, throw exception, or use Optional).
Recap the design, emphasizing the use of indexes and error handling. Mention possible extensions like pagination, search by partial name, or persistence.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.