Leetcode Problem 2590. Design a Todo List

2590. Design a Todo List

Leetcode Solutions

Using HashMaps and Custom Task Class

  1. Define a Task class with attributes for ID, description, due date, completion status, and tags.
  2. Initialize a HashMap in the TodoList class to store user IDs and their tasks.
  3. Implement addTask by creating a new Task object and adding it to the user's task list, incrementing the task ID each time.
  4. Implement getAllTasks by filtering the user's task list for uncompleted tasks and sorting by due date.
  5. Implement getTasksForTag similarly to getAllTasks, but also filter by the given tag.
  6. Implement completeTask by finding the task with the given ID and marking it as complete.
UML Thumbnail

Using Simple Lists and Task ID Mapping

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...