636. Exclusive Time of Functions
On a single threaded CPU, we execute some functions. Each function has a unique id between 0 and N-1.
We store logs in timestamp order that describe when a function is entered or exited.
Each log is a string with this format: "{function_id}:{"start" | "end"}:{timestamp}". For example, "0:start:3" means the function with id 0 started at the beginning of timestamp 3. "1:end:2" means the function with id 1 ended at the end of timestamp 2.
A function's exclusive time is the number of units of time spent in this function. Note that this does not include any recursive calls to child functions.
Return the exclusive time of each function, sorted by their function id.
Example 1:

Note:
1 <= n <= 100Two functions won't start or end at the same time.
Functions will always log when they exit.
Last updated
Was this helpful?