```
public int sumOfLeftLeaves(TreeNode root) {
return sum(root,-1);
}
public int sum(TreeNode root,int isLeft){//isLeft=1 if first parameter is a left child else 0
if(root == null)
return 0;
if(root.left==null && root.right==null && isLeft == 1){
return root.val;
}
return sum(root.left,1)+sum(root.right,0);
}
```