/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
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));
}
}

  

100. Same Tree(Tree)的更多相关文章

  1. Leetcode算法刷题:第100题 Same Tree

    Same Tree 题目 给予两棵二叉树,判断这两棵树是否相等(即各节点的值都一样) 解题思路 分别遍历两棵二叉树,并用列表分别存储这两棵树的节点的值,比较这两个列表就可以了 class Soluti ...

  2. 100. Same Tree (Tree;DFS)

    Given two binary trees, write a function to check if they are equal or not. Two binary trees are con ...

  3. LeetCode(100)题解--Same Tree

    https://leetcode.com/problems/same-tree/ 题目: Given two binary trees, write a function to check if th ...

  4. LeetCode(100) Same Tree

    题目 Given two binary trees, write a function to check if they are equal or not. Two binary trees are ...

  5. [LeetCode]题100:Same Tree

    Given two binary trees, write a function to check if they are the same or not. Two binary trees are ...

  6. leetcode@ [236] Lowest Common Ancestor of a Binary Tree(Tree)

    https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ Given a binary tree, find the ...

  7. LeetCode :: Convert Sorted Array (link list) to Binary Search Tree [tree]

    1.Given an array where elements are sorted in ascending order, convert it to a height balanced BST. ...

  8. 98. Validate Binary Search Tree (Tree; DFS)

    Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as ...

  9. 101. Symmetric Tree (Tree, Queue; DFS, WFS)

    Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For e ...

随机推荐

  1. shell 工具

    http://zouqingyun.blog.51cto.com/782246/1696340

  2. jquery中的each方法,$.each \ this.each \ $.fn.each

    jquery.each 方法 方法一 $("img").each(function(i,elem){ // i 下标 从零开始, // elem == this // $(elem ...

  3. iptables基础信息介绍

    在linux系统下,网络安全,除了有SElinux,另外就是iptables防火墙了,这个是用的最多也是功能非常强大的一个工具,今天就对其简单的架构上技术进行概要描述.让自己后续能够逻辑清晰的处理云环 ...

  4. Ruby Numeric

    Numeric |-- Float |-- Integer |-- Fixnum |-- Bignum Numeric的基本结构 整数的差异,一般的数字Fixnum就能够处理,即使超过了Fixnum的 ...

  5. Visual对象之DrawingContext.DrawRectangle在有的状态下似乎并不能提高性能

    很多书上都提到使用Visual对象绘制图形可以提高绘图效率,但是经过本人亲测,结果却发现DrawingContext.DrawRectangle的效率远低于使用UIElement.Children.A ...

  6. Redis-sentinel监控

    Sentinel介绍 Redis的 Sentinel 系统用于管理多个Redis服务器, 该系统执行以下三个任务: 监控(Monitoring) 提醒(Notification) 自动故障迁移(Aut ...

  7. CentOS下用pyenv 和 virtualenv 搭建单机多版本python 虚拟开发环境

    安装 系统环境:CentOS 6.5 安装依赖 yum -y install gcc gcc-c++ make git patch openssl-devel zlib-devel readline- ...

  8. windows类书的学习心得(转载)

    原文网址:http://www.blogjava.net/sound/archive/2008/08/21/40499.html 现在的计算机图书发展的可真快,很久没去书店,昨日去了一下,真是感叹万千 ...

  9. 访问修饰符internal

    internal(C# 参考) internal 关键字是类型和类型的成员 访问修饰符. 只有在同一程序集的文件中,内部类型或成员才是可访问的,如下例所示: public class BaseClas ...

  10. HttpUrlConnection java.net.SocketException: Software caused connection abort: recv failed

    最近做java swing程序在模拟httprequest请求的时候出现了这个错误 java.net.SocketException: Software caused connection abort ...