leetcode 113. Path Sum II
来源:互联网 发布:linux书籍 编辑:程序博客网 时间:2024/05/19 20:38
class Solution {public:vector<vector<int>> pathSum(TreeNode* root, int sum){if (root == nullptr){return{};}target = sum;process(root, {}, 0);return res;}private:int target;vector<vector<int>> res;void process(TreeNode* root, vector<int> temp, int now){temp.push_back(root->val);if (root->left == nullptr && root->right == nullptr){if (now + root->val == target){res.push_back(temp);}return;}if (root->left){process(root->left, temp, now + root->val);}if (root->right){process(root->right, temp, now + root->val);}}};
0 0
- LeetCode 113. Path Sum II
- [LeetCode]113.Path Sum II
- [Leetcode] 113. Path Sum II
- [leetcode] 113.Path Sum II
- [LeetCode]113. Path Sum II
- LeetCode: 113. Path Sum II
- leetcode 113. Path Sum II
- 113. Path Sum II LeetCode
- leetcode 113. Path Sum II
- LeetCode *** 113. Path Sum II
- Leetcode 113. Path Sum II
- LeetCode 113. Path Sum II
- LeetCode 113. Path Sum II
- LeetCode - 113. Path Sum II
- Leetcode 113. Path Sum II
- [LeetCode] 113. Path Sum II
- [leetcode] 113. Path Sum II
- [LeetCode] 113. Path Sum II
- NGUI3.11 离线Document文档
- css图片等比列放大
- HM编码器代码阅读(35)——帧内预测(二)帧内预测总流程
- 求排列的逆序数
- windows和linux进程间与线程间通信
- leetcode 113. Path Sum II
- 数据单向绑定
- Ubuntu16.4 安装 redis
- 集中日志服务器Rsyslog
- poj3304Segments(线段与直线相交)
- 《JS高程(3)》DOM2和DOM3-样式、视口尺寸问题-第12章笔记(23)
- js创建新的节点
- 137. Single Number II
- Let's Encrypt永久免费SSL证书过程教程及常见问题