Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 | 11x 6x 5x 2x 3x | import type { TreeNode } from './Tree'
export default function sumOfLeftLeaves(root: TreeNode<number> | null): number {
if (root === null)
return 0
if (root.left !== null && root.left.left === null && root.left.right === null)
return root.left.val + sumOfLeftLeaves(root.right)
return sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right)
}
|