/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/funcsumOfLeftLeaves(root*TreeNode)int{ifroot==nil||root.Left==nil&&root.Right==nil{return0}res,curDepth:=0,0vardfsfunc(root*TreeNode,depthint)dfs=func(root*TreeNode,depthint){ifroot!=nil{depth++ifroot.Left==nil&&root.Right==nil{ifdepth>curDepth{res+=root.ValcurDepth=depth}return}dfs(root.Left,depth)dfs(root.Right,depth)}}dfs(root,0)returnres}
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/funcsumOfLeftLeaves(root*TreeNode)int{ifroot==nil{return0}res,curDepth:=0,0vardfsfunc(root*TreeNode,depthint,isLeftbool)dfs=func(root*TreeNode,depthint,isLeftbool){ifroot!=nil{depth++ifroot.Left==nil&&root.Right==nil{ifdepth>curDepth&&isLeft{res+=root.ValcurDepth=depth}return}dfs(root.Left,depth,true)dfs(root.Right,depth,false)}}dfs(root,0,false)returnres}
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/funcsumOfLeftLeaves(root*TreeNode)int{res:=0vardfsfunc(root*TreeNode,isLeftbool)dfs=func(root*TreeNode,isLeftbool){ifroot!=nil{ifroot.Left==nil&&root.Right==nil{ifisLeft{res+=root.Val}return}dfs(root.Left,true)dfs(root.Right,false)}}dfs(root,false)returnres}