Exclusive Time of Functions
Understand how to calculate the exclusive running time of multiple functions based on start and end logs in a single-threaded CPU environment. Explore stack usage to track function execution and preemption, enabling accurate time computation across nested calls. Implement solutions in Python to get hands-on experience with this common coding interview pattern.
We'll cover the following...
Statement
We are given an integer number, n, representing the number of functions running in a single-threaded CPU, and an execution log, which is essentially a list of strings. Each string has the format {function id}:{"start" | "end"}:{timestamp}, indicating that the function with function id either started or stopped execution at the time identified by the timestamp value. Each function has a unique ID between and . Compute the exclusive time of the functions in the program.
Note: The exclusive time is the sum of the execution times for all the calls to a specific ...