Search⌘ K
AI Features

Exclusive Time of Functions

Understand how to calculate the exclusive runtime of functions given their start and end logs in a single-threaded environment. Explore using stack data structures to manage function calls and pauses. This lesson helps you develop a reliable approach to track and compute each function's total execution time accurately.

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 ...