class Solution {
public:
vector<int> v1;
vector<int> v2;
void GetLeaf(TreeNode* tree, int type)
{
if (tree->left != NULL || tree->right != NULL)
{
if (tree->left != NULL)
{
GetLeaf(tree->left, type);
}
if (tree->right != NULL)
{
GetLeaf(tree->right, type);
}
}
else
{
if (type == )
{
v1.push_back(tree->val);
}
else
{
v2.push_back(tree->val);
}
}
}
bool leafSimilar(TreeNode* root1, TreeNode* root2) {
GetLeaf(root1, );
GetLeaf(root2, );
if (v1.size() != v2.size())
{
return false;
}
for (int i = ; i < v1.size(); i++)
{
if (v1[i] != v2[i])
{
return false;
}
}
return true;
}
};

leetcode872的更多相关文章

  1. [Swift]LeetCode872. 叶子相似的树 | Leaf-Similar Trees

    Consider all the leaves of a binary tree.  From left to right order, the values of those leaves form ...

  2. LeetCode872. Leaf-Similar Trees

    自己的代码: # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = ...

  3. Leetcode872.Leaf-Similar Trees叶子相似的树

    请考虑一颗二叉树上所有的叶子,这些叶子的值按从左到右的顺序排列形成一个 叶值序列 . 举个例子,如上图所示,给定一颗叶值序列为 (6, 7, 4, 9, 8) 的树. 如果有两颗二叉树的叶值序列是相同 ...

  4. LeetCode872. 叶子相似的树

    题目 1 class Solution { 2 public: 3 vector<int>ans1; 4 vector<int>ans2; 5 bool leafSimilar ...

  5. LeetCode 872. 叶子相似的树(Leaf-Similar Trees)

    872. 叶子相似的树 872. Leaf-Similar Trees 题目描述 请考虑一颗二叉树上所有的叶子,这些叶子的值按从左到右的顺序排列形成一个叶值序列. LeetCode872. Leaf- ...

随机推荐

  1. Django框架(三)

    0627内容: 上节回顾: 1. FBV.CBV 2. 数据库操作 class UserGroup(models.Model): """ 部门 3 "" ...

  2. OC-常见归档总结

    /*****  该文一共总结了以下六种文件操作   1.NSKeyedArchiver. 2.对类对象进行归档 <NSCoder>协议 3.文件管理类 NSFileManger  4.对文 ...

  3. DRF 权限的流程

    DRF 权限的流程 django rest framework,入口是 dispatch,然后依次 --->>封装请求--->>处理版本--->>>认证--- ...

  4. json 和 table控件

    <!DOCTYPE html><html> <head> <meta http-equiv="Content-Type" content= ...

  5. Compiling OpenGL games with the Flash C Compiler (FlasCC)

    Compiling OpenGL games with the Flash C Compiler (FlasCC) In this article I show how to use the Flas ...

  6. kali视频学习(11-15)

    第四周kali视频(11-15)学习 11.漏洞分析之OpenVAS使用 12.漏洞分析之扫描工具 13.漏洞分析之WEB爬行 14.漏洞分析之WEB漏洞扫描(一) 15.漏洞分析之WEB漏洞扫描(二 ...

  7. 微型 Python Web 框架: Bottle

    微型 Python Web 框架: Bottle 在 19/09/11 07:04 PM 由 COSTONY 发表 Bottle 是一个非常小巧但高效的微型 Python Web 框架,它被设计为仅仅 ...

  8. HWOJ-求字符串最后一个单词的长度

    题目:给定一个字符串,求最后一个单词的长度,每个单词中间有空格. 例如:输入:hello world   输出:5 C代码:通过. #include <stdio.h> #define m ...

  9. 转载.Avalon-MM 阿窝龙妹妹应用笔记

    Avalon Interface Special http://www.altera.com.cn/literature/manual/mnl_avalon_spec.pdf Avalon总线是SOP ...

  10. 一次SQL Server 10054 Troubleshooting

    问题 对某个库新增了一个订阅节点,然后需要把一些应用切到新订阅库,以分散负载.当应用切换后,有一个应用每次启动不到30秒,总是报超时的错误,而error log中又没有任何记录: Timeout ex ...