原文:[LeetCode] Sum of Left Leaves 左子叶之和

Find the sum of all left leaves in a given binary tree. Example: 这道题让我们求一棵二叉树的所有左子叶的和,那么看到这道题我们知道这肯定是考二叉树的遍历问题,那么最简洁的写法肯定是用递归,由于我们只需要累加左子叶之和,那么我们在进入递归函数的时候需要知道当前结点是否是左子节点,如果是左子节点,而且该左子节点再没有子节点了说明其是左子 ...

2016-09-30 13:40 1 7986 推荐指数:

查看详情

leetcode】1302. Deepest Leaves Sum

题目如下: Given a binary tree, return the sum of values of its deepest leaves. Example 1: Constraints: The number of nodes ...

Sun Dec 29 16:58:00 CST 2019 0 224
LeetCode 15. 三数之和(3Sum

题目描述 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?找出所有满足条件且不重复的三元组。 注 ...

Fri May 04 19:25:00 CST 2018 1 7433
[LeetCode] Map Sum Pairs 映射配对之和

Implement a MapSum class with insert, and sum methods. For the method insert, you'll be given a pair of (string, integer). The string ...

Sun Oct 01 07:54:00 CST 2017 3 2781
[LeetCode]21. 3Sum三者之和

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum ...

Tue Oct 13 04:12:00 CST 2015 0 6050
LeetCode OJ:Three Sum(三数之和

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum ...

Tue Oct 06 05:12:00 CST 2015 0 3952
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM