[leetcode]Same Tree
Leetcode 之Same Tree(48)
用递归比较简单,这里用迭代的方式实现。注意什么时候返回true,什么时候返回false。 bool isSameTree(TreeNode *p, TreeNode *q) { stack<TreeNode *> s; s.push(p); s.push(q); w
日期 2023-06-12 10:48:40[LeetCode] 100. Same Tree ☆(两个二叉树是否相同)
描述 解析 根与根比较,左右子树互相递归比较即可。 代码 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } *
日期 2023-06-12 10:48:40[Leetcode]-Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. Hide
日期 2023-06-12 10:48:40Leetcode_num3_Same Tree
题目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 刷题打卡中。
日期 2023-06-12 10:48:40leetcode 100. Same Tree
Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. Ex
日期 2023-06-12 10:48:40Leetcode: Same Tree
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value.  
日期 2023-06-12 10:48:40[Leetcode] Same Tree
1最容易想到的递归调用 1 bool isSameTree(TreeNode *r1, TreeNode *r2) 2 { 3 if(r1 == NULL && r2 == NULL) return true; //终止条件 4 if(r1 == NULL || r2 == NULL) return false;//减枝,我觉得也是终止条件 5 6
日期 2023-06-12 10:48:40【LeetCode】100. Same Tree (2 solutions)
Same Tree Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value.  
日期 2023-06-12 10:48:40[LeetCode] 100. Same Tree 判断相同树
Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. Ex
日期 2023-06-12 10:48:40