Exclusive Time Of Functions
medium
1: On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1. 2: You are required to find the total execution time of each function. 3: You are given len number of logs, where logs[i] represents the ith log message formatted as a string "{function_id}:{"start" | "end"}:{timestamp}", telling start or end time of function with id function_id. Note that a function can be called multiple times, possibly recursively.
Constraints
1: 1 <= n <= 100 2: 0 <= function_id < n 3: No two start events will happen at the same timestamp. 4: No two end events will happen at the same timestamp. 5: Each function has an start time and an end time.
Format
Input
A number n representing number of functions. A number len representing count of logs. log1 log2 ...len number of logs.
Output
print in different lines Exclusive Time Of Functions from id 0 to n-1.
Example
Sample Input
2
4
0:start:0
1:start:2
1:end:5
0:end:6
Sample Output
3
4
Question Video