非常easy标题,在后面,我不认为它不是那么简单的回答更多的。我们将编写,没有人啊。

预购在基层上,加上节省每一层,加上从下往上的输出,是一家vector而一个stack那么问题,没有他,但另一方面-cooked首尔。

class Solution {
public:
vector<vector<int> > levelOrderBottom(TreeNode *root) {
vector<vector<int> > res;
if(root == NULL) return res;
queue<TreeNode*> que;
stack<vector<int> > s;
vector<int> tpres;
TreeNode *pNode;
que.push(root);
que.push(NULL);
while(!que.empty()){
pNode = que.front();
que.pop();
if(pNode == NULL){
s.push(tpres);
tpres.clear();
if(que.empty())
break;
else{
que.push(NULL);
continue;
}
}
tpres.push_back(pNode->val);
if(pNode->left)
que.push(pNode->left);
if(pNode->right)
que.push(pNode->right);
}
while(!s.empty()){
res.push_back(s.top());
s.pop();
}
return res;
}
};

leetcode先刷_Binary Tree Level Order Traversal II的更多相关文章

  1. Java for 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 left ...

  2. LeetCode 107 Binary Tree Level Order Traversal II(二叉树的层级顺序遍历2)(*)

    翻译 给定一个二叉树,返回从下往上遍历经过的每一个节点的值. 从左往右,从叶子到节点. 比如: 给定的二叉树是 {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7 返回它从下 ...

  3. [LeetCode] 107. Binary Tree Level Order Traversal II 二叉树层序遍历 II

    Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left ...

  4. (二叉树 BFS) 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 left ...

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

  6. leetcode 107 Binary Tree Level Order Traversal II ----- java

    Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left ...

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

  8. leetcode题解:Tree Level Order Traversal II (二叉树的层序遍历 2)

    题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from ...

  9. Java [Leetcode 107]Binary Tree Level Order Traversal II

    题目描述: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, fro ...

随机推荐

  1. SVN权限解析规则详解(转)

    首先创建一个版本库后,会生成最初的目录结构和基本的配置文件,本文主要分析“authz”文件的内容:我们先抛开alias和groups不谈,将重点放在路径的权限配置上. 一. 权限格式 svn权限的基本 ...

  2. perl的一些基本用法

    ReadLine support available (try 'install Bundle::CPAN')cpan>进入cpan的shell,好了,我为了安装spamassassin,需要安 ...

  3. Swift - 解析XML格式数据(分别使用GDataXML和DDXML)

    在做一些应用的时候经常需要用到XML解析,比如获取Web Service数据,读取RSS新闻或者博客数据源.下面演示了两个非常方便高效的XML库在Swift里的调用方法. 假设需要被解析的XML数据文 ...

  4. 如何在Android Studio上使用Github

    首先,登陆到Github上并创建一个新repository.在屏幕右上角,点击“+”标记,并且选择“New repository”. 现在完成这个表格以新建一个叫做testproject的新repos ...

  5. common lisp wiki

    CLiki: index   http://www.cliki.net/

  6. [C++]C++中的运行时类型检测

    Date:2014-1-3 Summary: 使用C++中的运行时类型检测.(文章重点在于记录本人的使用情况,并非深层讨论RTTI) Contents:写习惯C#的我,在C++依然存在哪些.NET的惯 ...

  7. [Xcode]SVN的使用

    当发生冲突时: (p)postpone: -mark the conflict be resolved later 保持冲突,手动修改源文件解决冲突 (df)diff-full: -show all ...

  8. 从iReport至Jaspersoft Studio

    这篇文章同步到http://www.waylau.com/from-ireport-to-jaspersoft-studio/ 从5.5版本号開始,Jaspersoft Studio将代替iRepor ...

  9. 2013 吉林通化邀请赛 Play Game 记忆化搜索

    dp[ba][ta][bb][tb]表示a堆牌从下面拿了ba张,从上面拿了ta张.b堆牌从下面拿了bb张,从上面拿了tb张.当前玩家能得到的最大的分数. 扩展方式有4种,ba+1,ta+1,bb+1, ...

  10. linux在下面APK反编译软件和过程的描述

    需要的工具: 1.apktool apk打包工具 下载地址:http://android-apktool.googlecode.com/files/apktool1.5.2.tar.bz2 安装:直接 ...