112

路径总和
给定一个二叉树和一个目标和,判断该树中是否存在根节点到叶子节点的路径,这条路径上所有节点值相加等于目标和。

说明: 叶子节点是指没有子节点的节点。

示例:
给定如下二叉树,以及目标和 sum = 22,

          5
         / \
        4   8
       /   / \
      11  13  4
     /  \      \
    7    2      1

返回 true, 因为存在目标和为 22 的根节点到叶子节点的路径 5->4->11->2。

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */


bool hasPathSum(struct TreeNode* root, int sum){
    if(!root) return false;
    if(!root->left && !root->right) return root->val == sum;
    return hasPathSum(root->left, sum - root->val) ||
    hasPathSum(root->right, sum - root->val);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
INTRODUCTION This current release of the RF High Power Products Design Kit for ADS v2004a has been implemented as follows: • The Library is implemented as an Agilent® EEsof® EDA Advanced Design System (ADS) Design Kit and should be installed according to Agilent's instructions on installing Design Kits. • There is now only one Zip file for all of the major platforms that Freescale Semiconductor supports (Microsoft® Windows® 2000, XP, Solaris® 8/9, HP-UX® 11.0/11.11i) and Red Hat® Linux® 7.2/7.3/8.0. This is because ADS v2004a now allows the use of dynamically linked or shared-object libraries for distribution of user-compiled models. We are no longer required to provide a new simulator executable for each computing platform. • The Design Kit was implemented per Agilent's instructions contained in the Design Kit Development Manual (dated September 2004). Therefore, the structure of our library has been modified per Agilent's requirements so that Agilent can help support installation and simulation issues in the future. Because of this modification, we must now use a new element called TechInclude (see “Release Notes, TechInclude Element” in this document). The TechInclude element is now required on all top-level schematics for simulation purposes. • The Library release includes the following: − Addition of lower thermal resistance package “H” models − The latest release is compatible with previous library releases. − MRF6P21190H and MRF28* models have been updated. − New MRF6S21140H model The Freescale Semiconductor RF Modeling Team highly recommends that you read through this document thoroughly to enable a smooth installation and transition to the new release.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值