Back to problems

Compute Exclusive Time from Stack Events

Algorithm · Anthropic · Medium

Implement exclusive_function_times(events) that consumes a single-threaded call trace and returns the aggregate exclusive execution time for every distinct function name. Every entry in events has the form [function_name, kind, timestamp]: function_name is a non-empty string. kind is either "start" or "end". timestamp is a non-negative integer. The events are ordered by nondecreasing timestamp. When several events share the same timestamp, process them in the order they…

Checking your access…