Best Solution 0ms

/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
bool isSameTree(struct TreeNode* p, struct TreeNode* q) {

  if (p==NULL&&q==NULL)
    return 1;
  else if ((!p&&q)||(p&&!q))
    return 0;
  return (isSameTree(p->left,q->left)&&isSameTree(p->right,q->right))&&(p->val==q->val);

}

转载于:https://www.cnblogs.com/CathyXiaohe/p/4985413.html

Xiaohe-LeetCode 100 Same Tree相关推荐

  1. LeetCode 100. Same Tree

    LeetCode 100. Same Tree Solution1: 这种弱智题提交这么多次... /*** Definition for a binary tree node.* struct Tr ...

  2. [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 ...

  3. [LeetCode]: 100: Same Tree

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

  4. [leetcode]100.Same Tree

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

  5. leetcode 100.Same Tree

    这道题目我最初想的太多了,导致做了好久,之后从网上一看,一下醒悟过来,不难. 题目: Given two binary trees, write a function to check if they ...

  6. LeetCode 589. N-ary Tree Preorder Traversal-多子节点树前序遍历--递归,迭代--反向压栈--C++解法

    LeetCode 589. N-ary Tree Preorder Traversal-多子节点树前序遍历–递归,迭代–反向压栈–C++解法 LeetCode题解专栏:LeetCode题解 LeetC ...

  7. 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 ...

  8. 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 ...

  9. LeetCode: Flatten Binary Tree to Linked List

    LeetCode: Flatten Binary Tree to Linked List LeetCode: Flatten Binary Tree to Linked List Given a bi ...

  10. 【重点】LeetCode 124. Binary Tree Maximum Path Sum

    LeetCode 124. Binary Tree Maximum Path Sum 参考链接:http://zxi.mytechroad.com/blog/tree/leetcode-124-bin ...

最新文章

  1. 新科技快速指南系列之“5G”:历史、现在与未来
  2. 语音视频社交背后技术深度解析
  3. JAVA包装类及自动封包解包示例代码
  4. #if defined和#if !defined的含义
  5. python一对一视频教学-使用Python的Tornado框架实现一个一对一聊天的程序
  6. Linux开发终端霓虹灯效果
  7. 内存模型以及分区,需要详细到每个区放什么
  8. DMA内存申请--dma_alloc_coherent 及 寄存器与内存【转】
  9. 安防意识增强 澳洲迈向新发展
  10. Robot Framework installation not found. To run tests, you need to install Robot Framework separately
  11. 全基因组组装,注释与评估软件
  12. 服务交付服务规范十要素
  13. 【JavaSE系列】世界上“最好的语言”——认识Java编程语言
  14. 台达服务器电源性能怎么样,台达电源怎么样?该怎么选择台达电源?
  15. 2013年7月美国Boston之旅
  16. 双十一秒杀架构模型设计
  17. supper 关键字
  18. SQL注入、XSS、XXE、CSRF、SSRF、越权漏洞、文件上传、文件包含总结篇
  19. Spring入门到精通:第二章 IOC容器(XML方式):1.IOC概念
  20. Apache-Hop构建本地web版本问题汇总

热门文章

  1. 市场聚焦:美国民用安防DIY需求大
  2. 利用BAPI(BAPI_GOODSMVT_CREATE)投料消耗(261)销售订单E库存
  3. 六大理由告诉你为什么 GNOME 仍然是最好的 Linux 桌面环境
  4. Three.js 模型闪烁重影(深度问题)
  5. 三星笔记本安装ubuntu10.04解决背景亮度不能调节问题
  6. pythonredis实例_python redis 删除key脚本的实例
  7. Unity笔记(10):SHOOT GAME EXAMPLE【2D】
  8. I am puzzled recently.
  9. 第70课:Spark SQL内置函数解密与实战 每天晚上20:00YY频道现场授课频道68917580
  10. html 编辑框 空值变红,HTML中关于表单的提交和输入的值是否为空