The Design a Todo List interview question asks you to create a system for managing tasks. Users can add tasks with descriptions and deadlines, mark tasks as completed, and query their pending tasks. You also need to support "tags" for tasks and allow users to filter their tasks by these tags. This Design a Todo List coding problem is a multi-dimensional data management challenge requiring efficient retrieval based on multiple criteria.
Notion and Bloomberg ask this to see how you organize relational data in an object-oriented way. It tests your proficiency with Design interview patterns, specifically how to handle sorting (by deadline), filtering (by tag), and state management (completed vs. pending). It evaluations your ability to choose the right data structures to keep the most common operations fast.
Task class with fields for id, description, deadline, tags, and isCompleted.Map<Integer, List<Task>> to store tasks for each user.taskId values for completion updates.getTasks, you’ll need to filter the user's list and then use a Sorting interview pattern to order by deadline.addTask(user:1, "buy milk", deadline:10, tags:["grocery"]): Task 1 created for User 1.addTask(user:1, "fix car", deadline:5, tags:["maintenance"]): Task 2 created for User 1.getTasks(user:1): Returns [Task 2, Task 1] because 5 < 10.completeTask(user:1, taskId:2): Task 2 is marked completed.getTasks(user:1): Now only returns [Task 1].Consider using a Priority Queue or a TreeMap if the list of tasks for a user grows very large and getTasks is called frequently. However, for most interview constraints, a List with a filter and sort is the cleanest and most communicative solution.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Invalid Transactions | Medium | Solve | |
| Group Anagrams | Medium | Solve | |
| Alert Using Same Key-Card Three or More Times in a One Hour Period | Medium | Solve | |
| Before and After Puzzle | Medium | Solve | |
| Design SQL | Medium | Solve |