Learn
Exam

Procrastinator

Difficulty
INTERMEDIATE

Problem

Park Lazy is a procrastinator.
Each day for n days, Park Lazy receives exactly one task (todo) to complete.
Each task includes its name, due date, and priority.

However, Park Lazy completes tasks only every other day.
The tasks are completed in the following order of priority:

  1. Tasks with earlier due dates are completed first.
  2. If multiple tasks have the same due date, the task with the higher priority is completed first.
  3. If multiple tasks have the same due date and priority, the task with the lexicographically smaller name is completed first.

Given the list of tasks todoList as input, write a solution function that returns the names of tasks completed by Park Lazy over 2n days, in the order they are completed.


Constraints

  • The length of todoList is at most 100,000.
  • Each element of todoList contains three values: name, due date, and priority.
    • name: A string of length 1 to 20, containing only lowercase English letters. Task names are unique.
    • due date: A string in the format MM/DD/YYYY, e.g., 12/31/2024.
    • priority: One of [CRITICAL, HIGH, MODERATE, LOW, MINIMAL], in decreasing order of priority:
      CRITICAL > HIGH > MODERATE > LOW > MINIMAL.

Test Case Explanation

Test Case Number todoList return
1 [["presentation","11/10/2030","HIGH"],["hotfix","11/10/2030","CRITICAL"],["laundry","11/10/2030","LOW"]] ["hotfix","presentation","laundry"]
2 [["meditation","06/15/2026","HIGH"],["workout","06/15/2026","CRITICAL"],["research","06/15/2026","MODERATE"],["booking","06/15/2026","LOW"],["cleaning","08/12/2025","LOW"]] ["workout","meditation","cleaning","research","booking"]
3 [["traveling","01/17/2026","MODERATE"],["hiking","01/17/2026","MODERATE"],["shopping","01/17/2026","MODERATE"]] ["hiking","shopping","traveling"]

Explanation for Test Case 1

  • The process of completing tasks is as follows:

    Day Current Pending Tasks Task Completed Today
    1 [["presentation","11/10/2030","HIGH"]] X
    2 [["presentation","11/10/2030","HIGH"]] "hotfix"
    3 [["presentation","11/10/2030","HIGH"],["laundry","11/10/2030","LOW"]] X
    4 [["laundry","11/10/2030","LOW"]] "presentation"
    5 [["laundry","11/10/2030","LOW"]] X
    6 [] "laundry"

Explanation for Test Case 2

  • The process of completing tasks is as follows:

    Day Current Pending Tasks Task Completed Today
    1 [["meditation","06/15/2026","HIGH"]] X
    2 [["meditation","06/15/2026","HIGH"]] "workout"
    3 [["meditation","06/15/2026","HIGH"],["research","06/15/2026","MODERATE"]] X
    4 [["research","06/15/2026","MODERATE"],["booking","06/15/2026","LOW"]] "meditation"
    5 [["cleaning","08/12/2025","LOW"],["research","06/15/2026","MODERATE"],["booking","06/15/2026","LOW"]] X
    6 [["research","06/15/2026","MODERATE"],["booking","06/15/2026","LOW"]] "cleaning"
    7 [["research","06/15/2026","MODERATE"],["booking","06/15/2026","LOW"]] X
    8 [["booking","06/15/2026","LOW"]] "research"
    9 [["booking","06/15/2026","LOW"]] X
    10 [] "booking"

Explanation for Test Case 3

  • The process of completing tasks is as follows:

    Day Current Pending Tasks Task Completed Today
    1 [["traveling","01/17/2026","MODERATE"]] X
    2 [["traveling","01/17/2026","MODERATE"]] "hiking"
    3 [["shopping","01/17/2026","MODERATE"],["traveling","01/17/2026","MODERATE"]] X
    4 [["traveling","01/17/2026","MODERATE"]] "shopping"
    5 [["traveling","01/17/2026","MODERATE"]] X
    6 [] "traveling"