You manage a collection of tasks. Each task has a unique integer ID, a name (string), a start time, and an end time. A task is considered active at a moment t if startTime <= t < endTime (start inclusive, end exclusive).
You receive a sequence of operations, each represented as a string. The two kinds of operations are:
"ADD_TASK id name startTime endTime" – adds a new task with the given ID, name, start time, and end time. All IDs are unique."QUERY t substring" – for this query, find every task that is active at time t and whose name contains the given substring (case‑sensitive). Return the IDs of those tasks sorted in ascending order.Your job is to process all operations in order and return a list of lists: for each QUERY, include the resulting sorted task IDs. If no task matches, the result for that query is an empty list.
Example 1:
Input: ops = ["ADD_TASK 1 alpha 0 10", "ADD_TASK 2 beta 5 7", "QUERY 6 a"]
Output: [[1,2]]
Explanation: At time 6, task 1 (name "alpha", active because 0 <= 6 < 10) and task 2 (name "beta", active because 5 <= 6 < 7) both have names containing "a". Sorted by ID gives [1,2].
ops = ["ADD_TASK 1 alpha 0 10", "ADD_TASK 2 beta 5 7", "QUERY 6 a"][[1,2]]
Two tasks have been added: Task 1 'alpha' (0 to 10) and Task 2 'beta' (5 to 7).
Example 2:
Input: ops = ["ADD_TASK 10 test 0 5", "QUERY 6 t"]
Output: [[]]
Explanation: Task 10 ends at 5. Time 6 is not less than its end time, so the task is inactive. No active tasks match, yielding an empty list.
Example 3:
Input: ops = ["ADD_TASK 3 abc 0 10", "ADD_TASK 4 xyz 0 10", "QUERY 5 def"]
Output: [[]]
Explanation: Both tasks are active at time 5, but neither name contains the substring "def". The output list is empty.
Constraints:
1 <= number of operations <= 20,000ADD_TASK or QUERY string as described.name is a non-empty string of length ≤ 10, containing only English letters.substring is a non-empty string of length ≤ 10, containing only English letters.0 <= startTime < endTime <= 10^90 <= t <= 10^9The same optimal solution that works for the original problem will pass all test cases here unchanged.
ops = ["ADD_TASK 1 alpha 0 10", "ADD_TASK 2 beta 5 7", "QUERY 6 a"][[1,2]]
Two tasks have been added: Task 1 'alpha' (0 to 10) and Task 2 'beta' (5 to 7).