Search⌘ K
AI Features

Exclusive Time of Functions

Understand how to analyze execution logs to compute the exclusive time each function runs on a single-threaded CPU. Explore using a stack data structure to track function start and end times, handle function preemption, and sum execution intervals accurately. Practice implementing a solution that parses logs, maintains state, and returns total run times for all functions.

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