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 ident ...
分类:
其他好文 时间:
2017-12-12 11:13:47
阅读次数:
159
思路1: 递归,如果 p = q, 那么判段 sameTree(p.left)==sameTree(q.left) and sameTree(p.right) = sameTree(q.right) 思路二: 如果两个树相同,说明按照一定的方式遍历这两个树,应该得到一样的结果。这里用的方法是使用st ...
分类:
其他好文 时间:
2017-01-25 07:44:44
阅读次数:
200
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 a ...
分类:
其他好文 时间:
2016-10-26 07:29:07
阅读次数:
215
题目:
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-07-06 21:49:34
阅读次数:
132
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-08-03 12:54:55
阅读次数:
201
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(...
分类:
其他好文 时间:
2014-06-25 18:42:46
阅读次数:
172