You are given execution logs from a single-threaded CPU that runs n functions labeled 0..n-1. The CPU can run only one function at a time. A function may call another function; when that happens, the caller is paused until the callee returns.
Each log entry is a string in the format:
"<function_id>:<event>:<timestamp>"
<event>
is either
"start"
or
"end"
.
timestamp
is a non-negative integer.
end
event at time
t
means the function finishes
at the end of time unit t
(i.e., inclusive end).
Return an array exclusiveTime of length n where exclusiveTime[i] is the exclusive CPU time spent executing function i (time spent in i itself, excluding time spent in functions called by i).
n
(number of functions)
logs
exclusiveTime
of length
n
Input:
n = 2
logs = [ "0:start:0", "1:start:2", "1:end:5", "0:end:6" ]
Output:
[3, 4]
Explanation (one valid interpretation):
1 <= n <= 10^5
1 <= logs.length <= 2 * 10^5