Search⌘ K
AI Features

Exclusive Time of Functions

Understand how to calculate the exclusive time of functions running on a single-threaded CPU by interpreting start and end logs. Learn to use stacks to manage function calls, handle preemption, and implement an efficient solution in Go. This lesson helps you practice solving complex time tracking problems using a coding approach aligned with interview patterns.

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