摘要:
思路:前序遍历 dfs前序遍历二叉树,记录每条路径是否满足和为sum,不满足则删去该结点,回溯到上一个结点。 代码: /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode le 阅读全文
摘要:
思路: 先序遍历,递归判断。 通过先序遍历,先判断B的根节点是否等于A中的一个节点,再从这个节点开始分别判断左子树和右子树是否相同。 代码: /** * Definition for a binary tree node. * public class TreeNode { * int val; * 阅读全文