This question evaluates a candidate's competence in scheduling and greedy algorithm design, including understanding of time-based constraints, efficient data-structure use, and reasoning about correctness.
You are given a set of tasks, each with a positive duration and a deadline (lastDay). You may schedule tasks in any order but only one at a time. Find the maximum number of tasks you can complete such that each chosen task finishes by its deadline. Return the count and describe an O(n log n) algorithm and its correctness intuition.