LeetCode 100. Same Tree
LeetCode 100. Same Tree
Solution1:
这种弱智题提交这么多次。。。
/*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(NULL) {}* };*/
class Solution {
public:bool isSameTree(TreeNode* p, TreeNode* q) {return my_Judge(p, q);}bool my_Judge(TreeNode* p, TreeNode* q) {if (p == NULL && q == NULL)return true;else if (p == NULL && q != NULL || q == NULL && p != NULL)return false;else if (p->val != q->val)return false;else {if (my_Judge(p->left, q->left) == false || my_Judge(p->right, q->right) == false)return false;elsereturn true;}}
};
LeetCode 100. Same Tree相关推荐
- [Leetcode]100. Same Tree -David_Lin
Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...
- [LeetCode]: 100: Same Tree
题目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are ...
- [leetcode]100.Same Tree
题目 Given two binary trees, write a function to check if they are the same or not. Two binary trees a ...
- leetcode 100.Same Tree
这道题目我最初想的太多了,导致做了好久,之后从网上一看,一下醒悟过来,不难. 题目: Given two binary trees, write a function to check if they ...
- LeetCode 589. N-ary Tree Preorder Traversal-多子节点树前序遍历--递归,迭代--反向压栈--C++解法
LeetCode 589. N-ary Tree Preorder Traversal-多子节点树前序遍历–递归,迭代–反向压栈–C++解法 LeetCode题解专栏:LeetCode题解 LeetC ...
- LeetCode: 107. Binary Tree Level Order Traversal II
题目 Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from l ...
- LeetCode: 103. Binary Tree Zigzag Level Order Traversal
题目 Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left ...
- LeetCode: Flatten Binary Tree to Linked List
LeetCode: Flatten Binary Tree to Linked List LeetCode: Flatten Binary Tree to Linked List Given a bi ...
- 【重点】LeetCode 124. Binary Tree Maximum Path Sum
LeetCode 124. Binary Tree Maximum Path Sum 参考链接:http://zxi.mytechroad.com/blog/tree/leetcode-124-bin ...
最新文章
- 5G NGC — 关键技术 — R16 eSBA
- 谷歌技术三宝之BigTable
- c++学习书籍推荐《Advanced C++》下载
- 利用matlab guide制作简易计算器
- 如何领导团队做好技术债管理?
- 【树】判断给定森林中有多少棵树(简单做法)
- Cmder 设置默认打开目录、解决中文乱码
- 火狐浏览器手机版_hao123导航app下载-hao123浏览器手机版下载
- H5测试是怎么做的?
- 【开源GPS追踪】 之 服务器端opengts安装
- 【教程】Edraw Max(亿图图示):使用免费模板和示例快速制作发票
- 使用CSS控制表单样式/示例演示
- c编程语言学习软件,用什么软件学习c语言
- 子群的陪集-》群的拉格朗日定理
- 计算机网络(2.10)物理层- 宽带接入技术-ADSL 技术
- Docker的Pull Digest和Image ID
- Sping Cloud专栏:路由Gateway有效避免 Only one connection receive subscriber allowed问题
- linux的ctrl alt f12,“Ctrl + Alt + F12”是做什么的?
- compiz的ubuntu10.04安装
- 【解决】Python程序运行时所占内存越来越大