Search topics...
All Problems

Exclusive Time of Functions

Solution Approach
Was this helpful?
Mediumos-flavorExpected: O(n) time, O(n) space
stack

Problem

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).
Reference solution unlocks after your first submission
Loading...