二叉树的路径和
来源:互联网 发布:java重载与多态 编辑:程序博客网 时间:2024/05/19 12:35
class Solution {public: /** * @param root the root of binary tree * @param target an integer * @return all valid paths */ vector<vector<int>> a; vector<int> b; int sum; int sum1; void look(TreeNode *root) { if(root==NULL) return ; sum+=root->val; b.push_back(root->val); if(sum==sum1&&root->left==NULL&&root->right==NULL) { a.push_back(b); b.pop_back(); sum-=root->val; return; } look(root->left); look(root->right); sum-=root->val; b.pop_back(); } vector<vector<int>> binaryTreePathSum(TreeNode *root, int target) { sum=0; sum1=target; look(root); return a; // Write your code here }};
0 0
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 二叉树的路径和
- 像“钢铁侠”埃隆·马斯克那样,成为超速学习者
- 变量、作用域和内存问题
- Redhat7.0下搭建邮件服务器(二)
- 把排序数组转换为高度最小的二叉搜索树
- MAC OS 运行hadoop提示util.NativeCodeLoader: Unable to load native-hadoop library for your platform的解决
- 二叉树的路径和
- JDK1.7源码笔记之LinkedList类
- [2017.4.18]IMWEB前端小白训练营日记(四)
- 李开复解读:未来人工智能的巨大商机
- slidingmenu_library侧滑实现
- MDK升级引起的类似.\Source\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\stm32f10x.h(298): error: #67: exp
- 等价二叉树
- 字节流与字符流的区别详解
- 并查集 模板