非常简单的一道题/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x...
分类:
其他好文 时间:
2014-07-07 16:25:49
阅读次数:
220
题目: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 ...
分类:
其他好文 时间:
2014-06-15 00:53:09
阅读次数:
314
同是递归简单题public class Solution { public boolean
isSameTree(TreeNode p, TreeNode q) { boolean flag = true; if(p == null
&& q == null) ...
分类:
其他好文 时间:
2014-06-09 13:46:23
阅读次数:
275
【题目】
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-06-02 11:03:03
阅读次数:
205
原题地址:https://oj.leetcode.com/problems/same-tree/题意:判断两棵树是否是同一棵树。解题思路:这题比较简单。用递归来做。首先判断两个根节点的值是否相同,如果相同,递归判断根的左右子树。代码:#
Definition for a binary tree n....
分类:
编程语言 时间:
2014-05-26 10:30:17
阅读次数:
289
题目: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...
分类:
其他好文 时间:
2014-05-23 12:40:21
阅读次数:
352
戳我去解题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 identic...
分类:
其他好文 时间:
2014-05-20 10:09:37
阅读次数:
201
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie
Same Tree
Total Accepted: 15922 Total
Submissions: 38418
Given two binary trees, write a function to check if they are equal o...
分类:
其他好文 时间:
2014-05-14 01:15:40
阅读次数:
293
这两道题,大同小异。
我都是用BFS,在遍历的过程,判断结构是否相同/对称,值是否相同。下面是AC代码: 1 /** 2 * Given a binary tree, check
whether it is a mirror of itself (ie, symmetric aroun...
分类:
其他好文 时间:
2014-05-05 09:48:26
阅读次数:
401