Anthropic·Software Engineer·Technical Phone Screen
- Given a single-threaded program's execution log (a list of timestamped BEGIN/END events for function IDs), compute the exclusive CPU time per function (not counting time spent in child calls), and also reconstruct which functions are on the call stack at a given query timestamp. The solution should run in O(n) time and use O(m + call depth) space. You also need to explain how you handle equal timestamps (END before BEGIN), half-open intervals, and edge cases like back-to-back events or a query time outside any active interval.
“This one took me a minute to even parse fully.”