2 parents 0586525 + f400d36 commit 42309aaCopy full SHA for 42309aa
1 file changed
leetcode3/최민지/636.py
@@ -0,0 +1,23 @@
1
+class Solution:
2
+ def exclusiveTime(self, n: int, logs: List[str]) -> List[int]:
3
+ res = [0] * n
4
+ stack = []
5
+ prev_time = 0
6
+
7
+ for log in logs:
8
+ fn_id, event, timestamp = log.split(":")
9
+ fn_id = int(fn_id)
10
+ curr_time = int(timestamp)
11
12
+ if event == "start":
13
+ if stack:
14
+ res[stack[-1]] += curr_time - prev_time
15
16
+ stack.append(fn_id)
17
+ prev_time = curr_time
18
+ else:
19
+ res[stack.pop()] += curr_time - prev_time + 1
20
+ prev_time = curr_time + 1
21
22
+ return res
23
0 commit comments