title: Sum Nodes K Th Level Tree Represented String
signature: sumNodesKThLevelTreeRepresentedString(tree, k) {
source_py: def sum_nodes_k_th_level_tree_represented_string(tree, k):
      level = (- 1)
      sum = 0
      n = len(tree)
      for i in range(n):
          if (tree[i] == '('):
              level += 1
          elif (tree[i] == ')'):
              level -= 1
          elif (level == k):
              sum += (ord(tree[i]) - ord('0'))
      return sum
source_cpp: int sum_nodes_k_th_level_tree_represented_string(string tree, int k) {
    int level = - 1;
    int sum = 0;
    int n = tree . length ( );
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( tree [ i ] == '(' ) level ++;
      else if ( tree [ i ] == ')' ) level --;
      else {
        if ( level == k ) sum += ( tree [ i ] - '0' );
      }
    }
    return sum;
  }