[leet code 100] same tree
1 题目
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 boolean isSameTree(TreeNode p,TreeNode q){
if (p == null || q == null) return (p == q);
return (p.val == q.val) && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
}
[leet code 100] same tree的更多相关文章
- 【Leet Code】Palindrome Number
Palindrome Number Total Accepted: 19369 Total Submissions: 66673My Submissions Determine whether an ...
- 100. Same Tree(C++)
100. Same Tree Given two binary trees, write a function to check if they are equal or not. Two binar ...
- LeetCode Javascript实现 100. Same Tree 171. Excel Sheet Column Number
100. Same Tree /** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; ...
- Proxmox VE中出现TASK ERROR: command 'apt-get update' failed: exit code 100的解决方法
问题描述: 出现这个错误一般在WEB或者在Proxmox VE的服务器上面能看到日志: PVE中出现TASK ERROR: command 'apt-get update' failed: exit ...
- 100.Same Tree(E)
100. same tree 100. Same Tree Given two binary trees, write a function to check if they are the same ...
- <LeetCode OJ> 100. Same Tree
100. Same Tree Total Accepted: 100129 Total Submissions: 236623 Difficulty: Easy Given two binary tr ...
- LeetCode 100. Same Tree (判断树是否完全相同)
100. Same Tree Given two binary trees, write a function to check if they are the same or not. Two bi ...
- Leet Code 771.宝石与石头
Leet Code编程题 希望能从现在开始,有空就做一些题,自己的编程能力太差了. 771 宝石与石头 简单题 应该用集合来做 给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头. S ...
- leetcode 100. Same Tree、101. Symmetric Tree
100. Same Tree class Solution { public: bool isSameTree(TreeNode* p, TreeNode* q) { if(p == NULL &am ...
随机推荐
- NC 日志文件注册
在实际开发中,例如接口向外系统发送数据,这些数据前台看不到,一般都是记录日志,然后在后台日志文件中查看.但是,用系统原本日志文件来看,有时会记录一些别的模块日志信息.所以,我们可以注册个自己的模块日志 ...
- Spring MVC 注解类型
Spring 2.5 引入了注解 基于注解的控制器的优势 1. 一个控制器类可以处理多个动作,而一个实现了 Controller 接口的控制器只能处理一个动作 2. 基于注解的控制器的请求映射不需要存 ...
- 【UI测试】--美观与协调性
- 在离线安装gazebo的时候可能在运行turtlebot_gazebo的时候会出现问题
问题显示如下 gzserver: /build/ogre-1.9-mqY1wq/ogre-1.9-1.9.0+dfsg1/OgreMain/src/OgreRenderSystem.cpp:546: ...
- 2017/2/5:oracle数据库的三大文件
oracle的三大文件: 一:控制文件:控制文件是一个小型的二进制文件,可以记录数据库的物理结构.包括: * 数据库名称 * 数据文件和日志文件的名称和位置 * 数据库创建的时 ...
- Flex labelFunction 用法
<mx:VBox horizontalAlign="left" height="100%" width="100%"> < ...
- myBatis中if test 字符串注意事项
错误写法: <if test="userName == 'boshen'"> AND `USER_NAME` = #{userName} </if> 正确写 ...
- 15-BOM
BOM的介绍 JavaScript基础分为三个部分: ECMAScript:JavaScript的语法标准.包括变量.表达式.运算符.函数.if语句.for语句等. DOM:文档对象模型,操作网页上的 ...
- springMVC注解(一)Controller
HelloWorld程序 Step1 编写web.xml文件 <?xml version="1.0" encoding="UTF-8"?> < ...
- Attach()和Detach()函数
一.Windows对象和MFC对象的区别? MFC对象实际上并没有把整个Windows对象都包装在其中.对于窗口:MFC对象它只是有一个窗口句柄而已,这个窗口句柄如果指向一个实际存在的窗口对象(窗口对 ...