Exclusive Function Time
Medium · Phone screen · Onsite · Full-time
Given function call logs on a single-threaded CPU, compute each function's exclusive execution time. I used a stack to track the currently running function and accumulated time. When a new function starts, I pause the current one. When one ends, I resume the parent. The interviewer asked about handling recursive calls and whether my approach would still work.
