Exclusive Execution Time of Functions
Compute exclusive execution times for all functions in the program.
Statement
We are given an integer number , representing the number of functions running in a single-threaded CPU, and a list of strings, where each string represents the start or end timestamp of a specific function. Each function has a unique ID between and . Compute the exclusive time of the functions in the program.
Note: Exclusive time is the sum of the execution times for all the calls to a specific function.
Constraints
- <=
n
<= - <=
logs.length
<= - <=
function_id
<n
- <=
timestamp
<= - No two start events and two end events will happen at the same timestamp.
- Each function has an “end” log entry for each “start” log entry.
Example
Consider the following list of strings, where each string represents the log entry formatted as:
{function_id}:{"start" | "end"}:{timestamp}
Each function is identified in the logs by a function ID:
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.