遇到树了!终于看起来高大上一点了= =比较两棵二叉树,相等则返回true。【思路】递归,if(p->val==q->val&&isSameTree(p->left,q->left)&&isSameTree(p->right,q->right)) return true.注意还要考虑特殊情况。【my ...
分类:
其他好文 时间:
2015-04-21 09:31:31
阅读次数:
193
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 an...
分类:
其他好文 时间:
2015-04-17 15:23:15
阅读次数:
107
题目链接: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....
分类:
其他好文 时间:
2015-04-14 21:41:41
阅读次数:
140
Same TreeTotal Accepted:56263Total Submissions:133912My SubmissionsQuestionSolutionGiven two binary trees, write a function to check if they are equal...
分类:
其他好文 时间:
2015-04-14 11:07:01
阅读次数:
110
判断两棵树是否对称 class Solution {public: bool isSameTree(TreeNode *p, TreeNode *q) { if (!p && !q) return true; if (p && !q) return false; if (!p && q) ...
分类:
其他好文 时间:
2015-04-11 11:40:44
阅读次数:
113
从今天起,模仿《从零单排》系列,菜鸡单刷LeetCode!...
分类:
其他好文 时间:
2015-04-07 21:46:39
阅读次数:
149
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....
分类:
其他好文 时间:
2015-04-07 11:59:15
阅读次数:
128
题目: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.
判断两棵二叉树是否相同。...
分类:
其他好文 时间:
2015-04-03 09:18:52
阅读次数:
138
Same Tree Total Accepted: 52651 Total Submissions: 125166 My Submissions Question Solution
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered e...
分类:
其他好文 时间:
2015-03-20 23:50:46
阅读次数:
166
题目:Same Tree
/**
* LeetCode Same Tree
* 题目:判断两棵树是否是完全相同的
* 思路:完全相同:1、结构相同;
* 2、值相同。
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* ...
分类:
其他好文 时间:
2015-03-17 20:14:14
阅读次数:
127