← 返回 amazon 的题目列表Function Inclusive and Exclusive Time Calculation
类型:online_judge
Given a list of function execution logs, calculate the inclusive and exclusive time for a target function. The log format is [function, start or end, timestamp] and the target function name is provided. Return the inclusive time (end time minus start time) and exclusive time (inclusive time minus the time spent on first-level calls).
Example:
Input: ['AB, start, 0', 'CD, start, 3', 'EF, start, 5', 'EF, end, 6', 'CD, end, 8', 'AB, end, 9'], target function "AB"
Output: inclusive time is 9, exclusive time is 2
Function signature:
def calculate_times(logs: List[str], target: str) -> Tuple[int, int]:
pass
Example
Input
['AB, start, 0', 'CD, start, 3', 'EF, start, 5', 'EF, end, 6', 'CD, end, 8', 'AB, end, 9']