题目:
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.
Ans...
分类:
编程语言 时间:
2015-01-12 16:44:08
阅读次数:
216
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; ...
分类:
其他好文 时间:
2015-01-09 14:06:02
阅读次数:
134
https://oj.leetcode.com/problems/same-tree/http://blog.csdn.net/linhuanmars/article/details/22839819/**
*Definitionforbinarytree
*publicclassTreeNode{
*intval;
*TreeNodeleft;
*TreeNoderight;
*TreeNode(intx){val=x;}
*}
*/
publicclassSolution{
publicbooleanis..
分类:
其他好文 时间:
2015-01-06 12:10:11
阅读次数:
135
题目:
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.
解决方...
分类:
其他好文 时间:
2014-12-28 23:47:47
阅读次数:
394
题目
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.
解答
...
分类:
其他好文 时间:
2014-12-21 16:38:18
阅读次数:
110
这道题的题意特别简单,就是对两个二叉树进行比对,判断两个二叉树是否完全相同。拿到这道题,既然和二叉树有关,那么必然是使用递归的。正好再熟悉一下递归,可惜,还是对递归没有太深刻的理解。导致写出来的代码始终未能通过。其实思路特别简单。class Solution {public: bool isS...
分类:
移动开发 时间:
2014-12-14 19:53:53
阅读次数:
152
题目Same Tree通过率42.0%难度EasyGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are ...
分类:
其他好文 时间:
2014-12-13 17:46:52
阅读次数:
138
标题:Same Tree通过率:42%难度简单Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are st...
分类:
其他好文 时间:
2014-12-11 20:48:26
阅读次数:
164
Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally ide...
分类:
其他好文 时间:
2014-12-01 23:49:09
阅读次数:
192
判断两个树是不是相等。思路:递归。当前节点相等,且他们左子树和右子树都相等。class Solution {public: bool isSameTree(TreeNode *p, TreeNode *q) { if (!p) return !q; if (...
分类:
其他好文 时间:
2014-11-27 01:30:45
阅读次数:
181