[LeetCode] Algorithms-257. Binary Tree Paths
来源:互联网 发布:中农数据食堂采配平台 编辑:程序博客网 时间:2024/06/10 14:27
描述
思路
代码
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: vector<string> binaryTreePaths(TreeNode* root) { vector<string> r; if(root == NULL) return r; string tem; tem = to_string(root->val); searchTree(root, r, tem); return r; } void searchTree(TreeNode* root, vector<string> &r, string tem) { if(root->left == NULL && root->right == NULL) r.push_back(tem); if(root->left != NULL) searchTree(root->left, r, tem + "->" + to_string(root->left->val)); if(root->right != NULL) searchTree(root->right, r, tem + "->" + to_string(root->right->val)); }};
阅读全文
0 0
- [LeetCode] Algorithms-257. Binary Tree Paths
- Algorithms—257.Binary Tree Paths
- [leetcode] 257. Binary Tree Paths
- 257. Binary Tree Paths LeetCode
- 【LeetCode】257. Binary Tree Paths
- LeetCode 257. Binary Tree Paths
- LeetCode *** 257. Binary Tree Paths
- leetcode 257. Binary Tree Paths
- LeetCode 257. Binary Tree Paths
- Leetcode 257. Binary Tree Paths
- LeetCode-257.Binary Tree Paths
- 【leetcode】257. Binary Tree Paths
- [Leetcode]257. Binary Tree Paths
- LeetCode - 257. Binary Tree Paths
- LeetCode 257. Binary Tree Paths
- [leetcode] 257. Binary Tree Paths
- LeetCode 257. Binary Tree Paths
- 257.[Leetcode]Binary Tree Paths
- 互联网家居:买与卖之间的博傻游戏
- 122. Best Time to Buy and Sell Stock II
- Redis设计与实现 --- 单机数据库
- vSAN架构细节(3)
- mac下hadoop环境的搭建以及碰到的坑点
- [LeetCode] Algorithms-257. Binary Tree Paths
- svn
- 35. Search Insert Position
- 我的第一篇博客
- 在docker环境部署RabbitMQ并使用
- pandas时间序列
- Tomcat基本配置及常见问题
- 【POJ
- C++封装select模型