力扣106 构造二叉树
摘要:class Solution { public: TreeNode* buildTree(vector<int>& inorder, vector<int>& postorder) { return reBuild(inorder, postorder); } TreeNode* reBuild(v
阅读全文
posted @
2022-09-24 15:40
Syukuu
阅读(20)
推荐(0)
力扣101 对称二叉树
摘要:class Solution { public: bool isSymmetric(TreeNode* root) { if (root == nullptr) return true; return Preocess(root->left, root->right); } bool Preoces
阅读全文
posted @
2022-09-24 15:38
Syukuu
阅读(20)
推荐(0)
力扣872 叶子相似的树
摘要:思路: 直接前序遍历两个树获得叶子节点,然后对vector容器进行比较 class Solution { public: bool leafSimilar(TreeNode* root1, TreeNode* root2) { vector<int> r1,r2; getLeaf(root1,r1)
阅读全文
posted @
2022-09-24 15:38
Syukuu
阅读(11)
推荐(0)