树的子结构
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32M,其他语言64M
热度指数:612839
本题知识点:
二叉树
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构)
笔记
收藏
纠错
树的子结构
返回全部题目
剑指Offer_编程题
列表加载中...
相似的企业真题
上一题
下一题
登录
/
注册
题解
讨论
通过的代码
我的提交
保存并调试
登录后即可保存代码及做题进度
求助
做题遇到困难?
场外求助
查看通过的代码
参与大家的讨论
查看编程常见问题
练习
考试
<
保存并调试之后,这里将会显示运行结果
/** public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } */ public class Solution { public boolean HasSubtree(TreeNode root1,TreeNode root2) { } }
/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { public: bool HasSubtree(TreeNode* pRoot1, TreeNode* pRoot2) { } };
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def HasSubtree(self, pRoot1, pRoot2): # write code here
/* public class TreeNode { public int val; public TreeNode left; public TreeNode right; public TreeNode (int x) { val = x; } }*/ class Solution { public bool HasSubtree(TreeNode pRoot1, TreeNode pRoot2) { // write code here } }
/* function TreeNode(x) { this.val = x; this.left = null; this.right = null; } */ function HasSubtree(pRoot1, pRoot2) { // write code here } module.exports = { HasSubtree : HasSubtree };
val = $val; } }*/ function HasSubtree($pRoot1, $pRoot2) { // write code here }
/* function TreeNode(x) { this.val = x; this.left = null; this.right = null; } */ function HasSubtree(pRoot1, pRoot2) { // write code here }