<awangdev>636. Exclusive Time of Functions_1.java
public int[] exclusiveTime(int n, List<String> logs) {
        
        int[] rst = new int[n];
        Stack<Integer> stack = new Stack<>();
        int timestamp = 0;
        for (String log : logs) {
            String[] parts = log.split(":");
            int task = Integer.parseInt(parts[0]);
            boolean start = parts[1].equals("start");
            int time = Integer.parseInt(parts[2]);
            
            if (!stack.isEmpty()) rst[stack.peek()] += time - timestamp;
            timestamp = time;
            
            if (start) stack.push(task);
            else {
                int endTask = stack.pop();
                rst[endTask] += 1; 
                timestamp++;
            }
        }
        return rst;
    }
public int [ ] sample_funcname ( int var_0 , List < String > var_3 ) {
  int [ ] var_4 = new int [ var_0 ] ;
  Stack < Integer > var_7 = new Stack < > ( ) ;
  int var_9 = 0 ;
  for ( String var_10 : var_3 ) {
    String [ ] var_13 = var_10 . split ( ":" ) ;
    int var_15 = Integer . parseInt ( var_13 [ 0 ] ) ;
    boolean var_20 = var_13 [ 1 ] . equals ( "start" ) ;
    int var_22 = Integer . parseInt ( var_13 [ 2 ] ) ;
    if ( ! var_7 . isEmpty ( ) ) var_4 [ var_7 . peek ( ) ] += var_22 - var_9 ;
    var_9 = var_22 ;
    if ( var_20 ) var_7 . push ( var_15 ) ;
    else {
      int var_27 = var_7 . pop ( ) ;
      var_4 [ var_27 ] += 1 ;
      var_9 ++ ;
    }
  }
  return var_4 ;
}
