Function exclusive time
Your task
A single-threaded program runs n functions identified by ids 0..n-1. You are given execution logs as strings "{id}:{start|end}:{timestamp}" in chronological order; a function may call others (nested) and may recurse. The exclusive time of a function is the total time spent in it not counting time spent in nested calls. start happens at the beginning of a timestamp and end at the end of a timestamp, so 0:start:0 then 0:end:0 is 1 unit. Return the exclusive time of each function, indexed by id.
Examples
exclusive_time(n: int, logs: list[str]) -> list[int]Example 1
Input
exclusive_time(2, ["0:start:0", "1:start:2", "1:end:5", "0:end:6"])Output
[3, 4]