Company: ibm_7nov
Difficulty: medium
Consolidate Runtimes Problem Description You are given log entries for several processes. Each entry has: the process ID (numbered from 0 to m-1), the start time (in seconds), and the end time (in seconds). Because a process may be paused and later resumed, it can show up across several separate time windows. For each process, merge any of its time windows that overlap, then total up how long it actually ran. Return an array of size m, where each element represents the total runtime of the corresponding process ID. Examples Example 1: Input: m = 2 processes, n = 5 log entries, runtimeLogs = [[0, 0, 3], [0, 7, 10], [1, 10, 15], [0, 20, 25], [1, 12, 18]] Output: [14, 9] Explanation: process ID | Log Entries | Merged Intervals | Total Runtime 0 | [0, 3], [7, 10], [20, 25] | [0, 7], [20, 25] | 8 + 6 = 14 1 | [10, 15], [12, 18] | [10, 18] | 9 Example 2: Input: m = 3 processes, n = 3 log entries, runtimeLogs = [[0, 1, 5], [2, 5, 8], [1, 2, 5]] Output: [5, 4, 4] Explanation: process ID | Log