comefrom: <doocs>0636.Exclusive Time of Functions_1.py
code: def exclusiveTime( n: int, logs: List[str]) -> List[int]:
      ans = [0] * n
      stk = []
      curr = -1
      for log in logs:
          t = log.split(':')
          fid = int(t[0])
          ts = int(t[2])
          if t[1] == 'start':
              if stk:
                  ans[stk[-1]] += ts - curr
              stk.append(fid)
              curr = ts
          else:
              fid = stk.pop()
              ans[fid] += ts - curr + 1
              curr = ts + 1
      return ans
masked: def sample_funcname ( var_0 : int , var_1 : List [ str ] ) -> List [ int ] :
      var_2 = [ 0 ] * var_0
      var_3 = [ ]
      var_4 = - 1
      for var_5 in var_1 :
          var_6 = var_5.split ( ':' )
          var_7 = int ( var_6 [ 0 ] )
          var_8 = int ( var_6 [ 2 ] )
          if var_6 [ 1 ] == 'start' :
              if var_3 :
                  var_2 [ var_3 [ - 1 ] ] += var_8 - var_4
              var_3.append ( var_7 )
              var_4 = var_8
          else :
              var_7 = var_3.pop ( )
              var_2 [ var_7 ] += var_8 - var_4 + 1
              var_4 = var_8 + 1
      return var_2
  