Search⌘ K
AI Features

Exclusive Time of Functions

Explore how to determine the exclusive runtime of multiple functions in a single-threaded CPU by analyzing their start and end logs. Understand how to use stack data structures to handle function preemption and compute accurate execution times.

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