Implement a key-value CRUD store
Company: DocuSign
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates understanding of core data structures, API design, complexity analysis, and edge-case handling for an in-memory key–value CRUD store, and falls under the Coding & Algorithms domain while testing both practical implementation skills and conceptual reasoning about time/space trade-offs.
Constraints
- 0 <= len(operations) <= 100000
- Each operation is valid and uses one of: 'put', 'get', 'update', 'delete', 'exists'
- Keys and values are non-empty strings with length at most 100
- Values will not be any reserved output token: 'CREATED', 'OVERWRITTEN', 'UPDATED', 'DELETED', 'NOT_FOUND', 'true', or 'false'
Examples
Input: ([['put','user:1','Alice'], ['get','user:1'], ['exists','user:1'], ['update','user:1','Alicia'], ['get','user:1'], ['delete','user:1'], ['get','user:1'], ['exists','user:1']],)
Expected Output: ['CREATED', 'Alice', 'true', 'UPDATED', 'Alicia', 'DELETED', 'NOT_FOUND', 'false']
Explanation: The key is created, read, updated, deleted, and then no longer exists.
Input: ([['put','a','1'], ['put','a','2'], ['get','a'], ['update','b','3'], ['delete','b'], ['exists','a']],)
Expected Output: ['CREATED', 'OVERWRITTEN', '2', 'NOT_FOUND', 'NOT_FOUND', 'true']
Explanation: The second put overwrites key 'a'. Updating and deleting missing key 'b' both fail.
Hints
- Only exact-key operations are required, so think about a structure that can check whether a key exists in expected O(1) time.
- Be careful to distinguish put from update: put can overwrite an existing key, while update should fail when the key is missing.