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. MVC框架中的值提供机制(二)

    在MVC框架中存在一些默认的值提供程序模板,这些值提供程序都是通过工厂模式类创建;在MVC框架中存在需要已Factory结尾的工厂类,在值提供程序中也存在ValueProviderFactories工 ...

  2. UICollectionView-网格视图

    1. UICollectionView 网格视图,除了提供与UITableView同样的功能显示一组顺序显示的数据,还支持多列的布局. 2. UICollectionView 使用 > 设置Co ...

  3. .NET学习路线之我见(转)

    这是我的第一篇博客,所以,我想写个大的,至少这个话题是比较大的. 在文章的开头,首先声明,这篇文章仅代表我个人的想法,并且只适合.NET的初学者,如果你已经有两年以上的开发经验,我劝你还是别看了,省得 ...

  4. Android application testing with the Android test framework

    目录(?)[-] Android automated testing 1 How to test Android applications Tip 2 Unit tests vs functional ...

  5. [置顶] Git 配置SSH简单玩法?

    > 第一步下载git点击直接下载 他会检测您的系统当前是64bit还是32bit安装过程不再啰嗦反正就是Next Next Next Finish 第二步这里你可以下载TortoiseGit点击 ...

  6. 如何突破 Java 程序员的分水岭

    第一阶段:一年之内的 JAVA 从业人员 这个阶段是你成长极快的阶段,而且你可能会经常加班.但是加班不代表你就可以松懈了,永远记得我说的那句话,从你入行那一刻起,你就要不停的学习.在这一年里,你至少需 ...

  7. Ubuntu16.04配置apache+php+mysql

    命令行配置apache input sudo apt-get install apache2 done! 命令行配置mysql 参见: MySQL install and setting 命令行配置p ...

  8. HihoCoder 1044 01-string 贪心

    1144 : 01串 时间限制:7000ms 单点时限:1000ms 内存限制:256MB 描述 给定两个整数n和m,求是否存在恰好包含n个0和m个1的01串S,使得S中不存在子串"001& ...

  9. minio  nginx 配置

    1. 参考配置  server { listen 80; server_name example.com; location / { proxy_set_header Host $http_host; ...

  10. centos 7 bbr 安装

    1. 准备 升级内核需要4.9 以及以上   2.  yum  内核升级       a. 添加 ELRepo 源 GPG key rpm --import https://www.elrepo.or ...