[leetcode]Binary Tree Preorder Traversal
来源:互联网 发布:怎样发淘宝链接给好友 编辑:程序博客网 时间:2024/06/07 00:44
Given a binary tree, return the preorder traversal of its nodes’ values.
For example:
Given binary tree {1,#,2,3},
1
\
2
/
3
树的前序遍历
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: vector<int> ans; vector<int> preorderTraversal(TreeNode *root) { if(root == NULL) return ans; ans.push_back(root->val); preorderTraversal(root->left); preorderTraversal(root->right); return ans; }};
0 0
- LeetCode Binary Tree Preorder Traversal
- 【LeetCode】Binary Tree Preorder Traversal
- Leetcode: Binary Tree Preorder Traversal
- Leetcode Binary Tree Preorder Traversal
- LeetCode:Binary Tree Preorder Traversal
- Leetcode: Binary Tree Preorder Traversal
- LeetCode:Binary Tree Preorder Traversal
- [LeetCode]Binary Tree Preorder Traversal
- [LeetCode] Binary Tree Preorder Traversal
- LeetCode | Binary Tree Preorder Traversal
- Leetcode: Binary Tree Preorder Traversal
- [LeetCode] Binary Tree Preorder Traversal
- LeetCode - Binary Tree Preorder Traversal
- LeetCode - Binary Tree Preorder Traversal
- 【LeetCode】Binary Tree Preorder Traversal
- [LeetCode]Binary Tree Preorder Traversal
- Binary Tree Preorder Traversal - LeetCode
- [Leetcode] Binary Tree Preorder Traversal
- Printf相关问题
- makefile 时 出现arm-linux-gcc: Command not found
- C++随记总结(1)----关于C++中的大小端、位段(惑位域)和内存对齐
- 静态库与动态库的区别?
- Latent semantic analysis note(LSA)
- [leetcode]Binary Tree Preorder Traversal
- 数据挖掘技术——分类树
- Linux常用命令大全
- java 实现WebService 以及不同的调用方式
- 使用LFM(Latent factor model)隐语义模型进行Top-N推荐
- C/C++位域知识小结
- start_kernel到init进程启动的过程
- 通过fastjson实现各种数据格式与json格式之间的数据转换
- 求一定范围内素数的个数