码迷,mamicode.com
首页 >  
搜索关键字:same-tree    ( 180个结果
LeetCode:Same Tree - 判断两颗树是否相等
1、题目名称 Same Tree(判断两棵树是否相等) 2、题目地址 https://leetcode.com/problems/same-tree/ 3、题目内容 英文:Given two binary trees, write a function to check if they are equal or not. Two b...
分类:其他好文   时间:2015-08-12 23:43:01    阅读次数:147
【LeetCode-面试算法经典-Java实现】【100-Same Tree(两棵树是否相同)】
【100-Same Tree(两棵树是否相同)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题  Given two binary trees, write a function to check if they are equal or not.   Two binary trees are considered equal if they are structural...
分类:编程语言   时间:2015-08-07 08:18:10    阅读次数:185
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...
分类:其他好文   时间:2015-08-02 08:55:40    阅读次数:114
Same Tree
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x...
分类:其他好文   时间:2015-07-28 17:27:48    阅读次数:85
leetcode167 Same Tree
题意:怎么判断两个二叉树相同思路:递归,值得注意的······需要判断树是否为空,否则会报超时的错····为什么是超时呢····奇怪代码:bool isSameTree(TreeNode* p, TreeNode* q) { if(p == NULL && q == NULL) ...
分类:其他好文   时间:2015-07-11 22:42:30    阅读次数:131
LeetCode Same Tree (判断相同树)
题意:如题思路:递归解决,同判断对称树的原理差不多。先保证当前两个结点是相等的,再递归保证两左结点是相等的,再递归保证右结点是相等的。 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int ...
分类:其他好文   时间:2015-07-10 00:08:15    阅读次数:243
【LeetCode 100_二叉树_遍历】Same Tree
解法一:递归 1 bool isSameTree(TreeNode* p, TreeNode* q) 2 { 3 if (p == NULL && q == NULL) 4 return true; 5 if ((p == NULL && q != NULL) || ...
分类:其他好文   时间:2015-07-05 19:55:23    阅读次数:97
Same Tree
废话不多说,直接上代码,哈哈,痛快:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL)...
分类:其他好文   时间:2015-07-02 14:10:48    阅读次数:91
Leetcode--easy系列5
#83 Remove Duplicates from Sorted List Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3...
分类:其他好文   时间:2015-06-24 19:01:53    阅读次数:123
leetCode(14):Invert Binary Tree and Same Tree
反转二叉树: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; ...
分类:其他好文   时间:2015-06-21 13:12:18    阅读次数:147
180条   上一页 1 ... 9 10 11 12 13 ... 18 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!