• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
UsSam
博客园 | 首页 | 新随笔 | 新文章 | 联系 | 订阅 订阅 | 管理

2014年3月15日

【Leetcode】Path Sum
摘要: 题目:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree andsum = 22, 5 / \ 4 8 / / \ 11 13 4 / ... 阅读全文
posted @ 2014-03-15 19:34 UsSam 阅读(97) 评论(0) 推荐(0)
 
【Leetcode】Maximum Depth of Binary Tree
摘要: 题目:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.解题思路:当节点为空时,返回0,否则返回左右儿子中最深的深度值。代码:/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode... 阅读全文
posted @ 2014-03-15 18:36 UsSam 阅读(119) 评论(0) 推荐(0)
 
 

公告


博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3