leetCode: same tree
来源:互联网 发布:游戏鼠标 知乎 编辑:程序博客网 时间:2024/06/14 10:45
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.
相当漂亮的解法
public class Solution {public boolean isSameTree(TreeNode p, TreeNode q) { if(p==null || q==null) { return p==q; } else return (p.val == q.val)&&isSameTree(p.left,q.left)&&isSameTree(p.right,q.right);} }
0 0
- Leetcode - Tree - Same Tree
- [leetcode][tree] Same Tree
- LeetCode: Same Tree
- LeetCode Same Tree
- [Leetcode] Same Tree
- LeetCode : Same Tree
- [LeetCode] Same Tree
- leetcode 65: Same Tree
- Leetcode 100 Same Tree
- [leetcode] Same Tree
- [LeetCode]Same Tree
- [leetcode]Same Tree
- [Leetcode]Same Tree
- Leetcode: Same Tree
- [LeetCode] Same Tree
- LeetCode-Same Tree
- [leetcode] Same Tree
- LeetCode - Same Tree
- 4.Boost之ref
- 5.Boost之“资源申请即初始化” RAII
- 6.Boost之smartpointer
- uva 1585 - Score
- APUE 第三章
- leetCode: same tree
- HDOJ题目4985Little Pony and Permutation(置换群)
- 7.Boost之thread
- 8.Boost之unordered_set
- POJ 2400 KM最小权匹配+输出所有配对方案
- 9.Boost之正则regex
- python pip通过本地目录安装相关程序包
- 1Boost之TCP,Client and Server
- 致我的未来