LeetCode257. Binary Tree Paths(dfs)
来源:互联网 发布:类似openvpn的软件 编辑:程序博客网 时间:2024/06/05 03:15
题目链接
输出dfs二叉树路径。
刚刷leetcode,跟ACM提交方式不一样,适应中。。。
class Solution {public: vector<string> binaryTreePaths(TreeNode* root) { vector<string> ans; if(root == NULL) return ans; dfs(ans, root, to_string(root->val)); return ans; } void dfs(vector<string> &ans, TreeNode* root, string s) { if(root->left==NULL && root->right==NULL){ ans.push_back(s); return; } if(root->left) dfs(ans, root->left, s+"->"+to_string(root->left->val)); if(root->right) dfs(ans, root->right, s+"->"+to_string(root->right->val)); }};
0 0
- LeetCode257. Binary Tree Paths(dfs)
- [LeetCode257] Binary Tree Paths
- leetcode257 Binary Tree Paths
- leetcode257---Binary Tree Paths
- LeetCode257:Binary Tree Paths
- LeetCode257. Binary Tree Paths
- leetcode257 Binary Tree Paths
- leetcode257. Binary Tree Paths
- LeetCode257——Binary Tree Paths
- 257. Binary Tree Paths(DFS)
- DFS:257. Binary Tree Paths
- LeetCode Binary Tree Paths 树 + DFS
- LeetCode 257 Binary Tree Paths (DFS)
- leetcode 257. Binary Tree Paths(DFS)
- DFS的应用——Binary Tree Paths
- leetcode 257. Binary Tree Paths 深度优先遍历DFS
- LeetCode(257)Binary Tree Paths
- Leetcode:257. Binary Tree Paths(JAVA)
- Java 基础 字符串 方法
- Android4.4深入浅出之SurfaceFlinger总体结构
- Centos7 修改运行级别
- 生成gtest静态库 libgtest.a文件
- // OC 中的 getter setter
- LeetCode257. Binary Tree Paths(dfs)
- LeetCode3. Longest Substring Without Repeating Characters
- 矩阵及其压缩存储
- Mysql单文件存储删除数据Bug文件容量不会减少
- LeetCode100. Same Tree
- iOS 保留两位小数 不四舍五入
- SpringMVC Controller 介绍
- 【产品评测】RPLIDAR A2 在WIN下测试
- 正则表达式匹配非空非中文