博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LeetCode] binaryTreePaths
阅读量:6931 次
发布时间:2019-06-27

本文共 774 字,大约阅读时间需要 2 分钟。

 

 

class Solution {public:    void binaryPath(TreeNode* root, vector
& result, string path) { if (root == NULL) { return; } if (path.empty()) { path = to_string(root->val); } else { path += "->" + to_string(root-> val); } if (root->left == NULL && root->right == NULL) { result.push_back(path); return; } if (root->left) { binaryPath(root->left, result, path); } if (root->right) { binaryPath(root->right, result, path); } } vector
binaryTreePaths(TreeNode* root) { vector
result; string path; binaryPath(root, result, path); return result; }};

 

转载地址:http://zbmjl.baihongyu.com/

你可能感兴趣的文章
工程中的文件介绍
查看>>
我的友情链接
查看>>
Mininet 更换版本问题
查看>>
eclipse快捷键总结
查看>>
Canal简介
查看>>
随机取表中的数据
查看>>
SpringCloud之Netflix服务发现(Eureka)
查看>>
spring 整合redis 简单使用
查看>>
xss ***
查看>>
cygwin(hadoop)卸载过程
查看>>
spring自动代理例子
查看>>
python ftp的上传和下载
查看>>
mysql(innodb)故障
查看>>
sed命令
查看>>
【date】显示系统当前时间
查看>>
p99延迟是什么
查看>>
Swift:一般继承父类的写法
查看>>
ssh使用公钥登录客户端设置
查看>>
月薪3万的程序员告诉你:这样工作才能拿高薪(转 IT之家)
查看>>
MySQL 文本文件的导入导出数据的方法
查看>>