树的后序遍历。

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. array_merge函数的注意事项

    array_merge — 合并一个或多个数组 array_merge() 将一个或多个数组的单元合并起来,一个数组中的值附加在前一个数组的后面.返回作为结果的数组 如果输入的数组中有相同的字符串键名 ...

  2. 表格表格中获取不到button选择器

    今天做一个表单提交,怎么也拿不到button的选择器,不管用$(“#btn_update”)还会getElementById("btn_update"),浏览器也是谷歌没问题,后来 ...

  3. Git学习笔记整理【图像解析、基础命令、分支、远程仓库】

    Git别名设置:https://www.cnblogs.com/hero123/p/9105381.html Git远程项目公钥配置:https://www.cnblogs.com/hero123/p ...

  4. 识别设备是IOS还是安卓

    var u = navigator.userAgent; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > - ...

  5. ionic2——安装并配置android sdk

    下载 android开发者官网下载sdk比较慢,甚至访问不了.所以建议去android中文网下载sdk,如下图找到android-sdk点击链接下载就行了 下载sdk 安装 安装前先要安装java j ...

  6. RESTful 组件

    1. CBV FBV: url("index/",index) # index(request) url("index/(\d+)",index) # inde ...

  7. PhotoShop使用指南(2)——下雨动画效果

    第一步: 第二步: 第三步: 第四步:

  8. POJ - 2079:Triangle (旋转卡壳,求最大三角形)

    Given n distinct points on a plane, your task is to find the triangle that have the maximum area, wh ...

  9. @Override重写

    package com.wisezone.f; //父类 public class Person { //姓名 private String name; //年龄 private int age; / ...

  10. [独孤九剑]Oracle知识点梳理(四)SQL语句之DML和DDL

    本系列链接导航: [独孤九剑]Oracle知识点梳理(一)表空间.用户 [独孤九剑]Oracle知识点梳理(二)数据库的连接 [独孤九剑]Oracle知识点梳理(三)导入.导出 [独孤九剑]Oracl ...