mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-16 03:59:18 +08:00
Add implementation of array binary tree.
Rewrite the tree serialization and deserialization methods. Add applications of array and linked list.
This commit is contained in:
@@ -59,15 +59,4 @@ public class TreeNode {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/* Get a tree node with specific value in a binary tree */
|
||||
public static TreeNode? GetTreeNode(TreeNode? root, int val) {
|
||||
if (root == null)
|
||||
return null;
|
||||
if (root.val == val)
|
||||
return root;
|
||||
TreeNode? left = GetTreeNode(root.left, val);
|
||||
TreeNode? right = GetTreeNode(root.right, val);
|
||||
return left ?? right;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user