public bool Solve(long[][] nodes) { if (nodes.Length == 0) { return(true); } Tree tree = new Tree(nodes); BinaryTreeTraversals binaryTreeTraversals = new BinaryTreeTraversals("TD1"); List <long> InOrderResult = binaryTreeTraversals.InOrder(tree.root); for (int i = 1; i < InOrderResult.Count; i++) { if (InOrderResult[i] <= InOrderResult[i - 1]) { return(false); } } return(true); }
public bool Solve(long[][] nodes) { if (nodes.Length == 0) { return(true); } Tree tree = new Tree(nodes); BinaryTreeTraversals binaryTreeTraversals = new BinaryTreeTraversals("TD1"); List <long> InOrderResult = new List <long>(); InOrderResult = binaryTreeTraversals.InOrder(tree.root); for (int i = 1; i < InOrderResult.Count; i++) { if (InOrderResult[i] < InOrderResult[i - 1]) { return(false); } } return(RecursiveCheck(tree.root, int.MinValue, int.MaxValue)); }