Search topics...

Exclusive Time of Functions

medium
os-flavorTime: O(n)Space: O(n)Frequency: 4

Given n functions with start/end logs on a single-threaded CPU, return the exclusive execution time of each function.

Example 1:

Input: n = 2, logs = ["0:start:0", "1:start:2", "1:end:5", "0:end:6"]
Output: [3, 4]
Explanation: Function 0 runs from 0-1 and 6-6 (3 units).
             Function 1 runs from 2-5 (4 units).
stack