This question evaluates object-oriented design, API and data-modeling skills, including selection of in-memory data structures, performance considerations, and handling of edge cases such as missing ids and duplicates.
Design an in-memory TODO list component that supports the following operations:
add(todo)
→ returns an
id
delete(id)
→ removes the entry if it exists
get_todo(id)
→ returns the TODO entry by id (or null/error if not found)
get_all()
→ returns all TODO entries
You may assume there is a helper:
check_todo(id) -> bool
which returns whether the entry has already been completed.
Clarify in your design:
get_all()
(insertion order? created time?)
No UI is required; focus on clean API, data model, and internal data structures.