摘要: import java.util.TreeSet; public class Algorithm { public static void main(String[] args) { String[] words = {"gin", "zen", "gig", "msg"}; System.out. 阅读全文
posted @ 2021-10-28 21:33 振袖秋枫问红叶 阅读(45) 评论(0) 推荐(0)
摘要: 深度优先搜索 class Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { /** * 如果根节点值大于两者,说明在根节点的左子树,小于则说明在右子树 * 在中间则说明根节 阅读全文
posted @ 2021-10-28 11:11 振袖秋枫问红叶 阅读(31) 评论(0) 推荐(0)
摘要: 深度优先搜索 class Solution { public TreeNode invertTree(TreeNode root) { if (root == null){ return null; } /** * 后序遍历 */ TreeNode left = invertTree(root.le 阅读全文
posted @ 2021-10-28 10:44 振袖秋枫问红叶 阅读(27) 评论(0) 推荐(0)