public static Node_856 Create(Node_856 parent) { return(new Node_856 { Parent = parent, Children = new List <Node_856>() }); }
private Node_856 CreateParanthesesTree(string parantheses) { Node_856 parent = Node_856.Create(null); for (var index = 0; index < parantheses.Length; index++) { //Case 1 : When value is '(' if (parantheses[index] == '(') { var node = Node_856.Create(parent); parent.Children.Add(node); parent = node; } //Case 2 : When value is ')' else { parent = parent.Parent; } } return(parent); }
private int CalculateScore(Node_856 node) { return(node.CalculateScore()); }