美文网首页
404. Sum of Left Leaves

404. Sum of Left Leaves

作者: matrxyz | 来源:发表于2018-01-16 13:22 被阅读0次

Find the sum of all left leaves in a given binary tree.

Example:

    3
   / \
  9  20
    /  \
   15   7

There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.

DFS:https://leetcode.com/problems/sum-of-left-leaves/discuss/88950
BFS:https://leetcode.com/problems/sum-of-left-leaves/discuss/89060

Solution:

思路:

Time Complexity: O(N) Space Complexity: O(N)

Solution Code:


相关文章

网友评论

      本文标题:404. Sum of Left Leaves

      本文链接:https://www.haomeiwen.com/subject/bzjsoxtx.html