树的后序遍历。

class Solution {
public:
vector<Node> Tree;
void postTree(Node node)
{
for (auto n : node.children)
{
Node node;
node = Node(n->val, n->children);
postTree(node);
}
Tree.push_back(Node(node.val, node.children));
} vector<int> postorder(Node* root) {
vector<int> V;
if (root != NULL)
{
postTree(*root);
}
for (auto n : Tree)
{
V.push_back(n.val);
}
return V;
}
};

leetcode590的更多相关文章

  1. Leetcode590. N-ary Tree Postorder Traversal

      590. N-ary Tree Postorder Traversal 自己没写出来   优秀代码: """ # Definition for a Node. cla ...

  2. LeetCode590. N叉树的后序遍历

    题目 1 class Solution { 2 public: 3 vector<int>ans; 4 vector<int> postorder(Node* root) { ...

  3. LeetCode 590. N叉树的后序遍历(N-ary Tree Postorder Traversal)

    590. N叉树的后序遍历 590. N-ary Tree Postorder Traversal 题目描述 给定一个 N 叉树,返回其节点值的后序遍历. LeetCode590. N-ary Tre ...

随机推荐

  1. Java中的算术运算符

    算术运算符主要用于进行基本的算术运算,如加法.减法.乘法.除法等. Java 中常用的算术运算符: 其中,++ 和 -- 既可以出现在操作数的左边,也可以出现在右边,但结果是不同滴 例1: 运行结果: ...

  2. ubuntu安装vmplayer出现问题的解决方法

    ubuntu安装vmplayer 出现问题的解决方法 1:ubuntu12.04安装vmware12出现cannot ope dev/vmmon及modprobe vmmon提示密钥无效的解决办法 笔 ...

  3. 运行php的时候出现计算机中丢失 MSVCR110.dll怎么解决

    运行php的时候出现计算机中丢失 MSVCR110.dll怎么解决 一.总结 一句话总结:因为现在php所有的 5.5 环境都是基于 vc11 的编译脚本下生成的,所以在 windows 下你得安装相 ...

  4. SSIS之序列容器

    序列容器是一种十分简单,但使用非常广泛的容器,它可以对控制流的任务流组件进行结构化处理,把一些业务相关的任务组件,放到一个序列容器中,使整个包看起来更加整洁.美观,就如同我们家里的书柜.衣柜似的,把不 ...

  5. JAVA实现多线程的四种方式

    JAVA多线程实现方式: 1.继承Thread类(无返回值) 2.实现Runnable接口(无返回值) 3.实现Callable接口,通过FutureTask包装器来创建Threak线程(有返回值) ...

  6. 简单使用location.hash的方法 ,怎么做,有什么用? 简单的js路由页面方法。

    hash 属性是一个可读可写的字符串,该字符串是URL的锚部分(从#号开始的部分).语法location.hash刚开始我真不知道hash有什么用,直到我在项目中遇上一个最大的问题.而且很恶心的体验 ...

  7. Git_学习_09_指定某些文件不上传

    一.前言 在git提交文件到远程分支时,可能有些文件我们并不想上传. 这时可以使用如下命令来将这些文件从暂存区移除 git rm --cached "文件路径" 注:git add ...

  8. New Concept English three (51)

    22 76 Predicting the future is notoriously difficult. Who could have imagined, in the mid 1970s, for ...

  9. "Cannot declare member function ...to have static linkage"错误

    英文解释: if you declare a method to be static in your .cc file. The reason is that static means somethi ...

  10. CodeForces - 438D: The Child and Sequence(势能线段树)

    At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at ...