2014.7.8fb

#include <iostream>
using namespace std; struct TreeNode{
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int val)
{
left = NULL;
right = NULL;
}
}; /* Input : binary tree A
/ \
B C
/ \ \
D E G
\ \
F H Output :
A
BC
DEG
FH
*/
vector<vector<int> > transform(TreeNode *root)
{
vector<vector<int> ans;
if(root == NULL)
return ans; vector<int> ans_piece;
queue<TreeNode *> last_time; queue.push_back(root);
TreeNode *temp; vector<int> num_each;
num_each.push_back();
num_each.push_back();
int level = ;
while(queue.empty() == false)
{
num_each[level]--; temp = queue.get_first_one();
queue.pop();
if(temp)
ans_piece.push_back(temp->val);
if(temp->left)
{
queue.push_back(temp->left);
num_each[level+]++;
}
if(temp->right)
{
queue.push_back(temp->right);
num_each[level+]++;
} if(num_each[level] == )
{
ans.push_back(ans_piece);
level++;
ans_piece.clear();
num_each.push_back();
}
}
return ans;
}

最新文章

  1. Ubuntu 15.1 unity在顶部面板显示系统CPU/内存/网络速度
  2. 将jetty嵌入到应用中的简单案例
  3. 从excel文件中获取数据(2)
  4. Zepto中文API
  5. 【分布式协调器】Paxos的工程实现-Cocklebur状态转移
  6. LeetCode : 223. Rectangle Area
  7. JIRA系统部署推进上线流程
  8. 搭建高性能计算环境(七)、应用软件的安装之MS
  9. eclipse界面语言的切换方法
  10. C++ Code_combobox
  11. 作品第一课----获取批量checkbox选中的值
  12. Android菜鸟的成长笔记(7)——什么是Activity
  13. 由Find All References引发的思考。,
  14. VMWare、KVM、Virtualbox克隆或复制Linux虚拟机后eth0找不到的解决方案
  15. 多线程:head first Thread.join()
  16. 运算符(C# 参考)
  17. java表达式类型的自动提升
  18. Gitflow工作流程
  19. (后端)spring的@Transactional注解详细用法(转)
  20. javaMail简介(一)

热门文章

  1. 科学计算库Numpy——数组形状
  2. linux Ubuntu18.04 安装配置MySQL
  3. day 44 前端HTML
  4. B1020 月饼(25 分)
  5. [BZOJ1597][Usaco2008 Mar]土地购买(斜率优化)
  6. 笔记-python-selenium,phantomjs
  7. EF上下文对象创建之线程内唯一
  8. TCP/IP网络编程之多种I/O函数
  9. Python中__str__和__repr__的区别
  10. django 开发之模型以及静态问题和图片的使用