| 123456789101112131415161718192021222324252627282930 | 
							- /**
 
-  * Definition for a binary tree node.
 
-  * type TreeNode struct {
 
-  *     Val int
 
-  *     Left *TreeNode
 
-  *     Right *TreeNode
 
-  * }
 
-  */
 
- func sumOfLeftLeaves(root *TreeNode) int {
 
- 	if root == nil {
 
- 		return 0
 
- 	}
 
- 	return sumRecurse(root, false)
 
- }
 
- func sumRecurse(root *TreeNode, isLeft bool) (sum int) {
 
- 	if root.Left == nil && root.Right == nil {
 
- 		if isLeft {
 
- 			return root.Val
 
- 		}
 
- 		return
 
- 	}
 
- 	if root.Left != nil {
 
- 		sum += sumRecurse(root.Left, true)
 
- 	}
 
- 	if root.Right != nil {
 
- 		sum += sumRecurse(root.Right, false)
 
- 	}
 
- 	return
 
- }
 
 
  |