We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7885414 commit ade452cCopy full SHA for ade452c
src/404. Sum of Left Leaves.js
@@ -0,0 +1,22 @@
1
+/**
2
+ * 404. Sum of Left Leaves
3
+ * https://leetcode.com/problems/sum-of-left-leaves/
4
+ * Definition for a binary tree node.
5
+ * function TreeNode(val) {
6
+ * this.val = val;
7
+ * this.left = this.right = null;
8
+ * }
9
+ */
10
11
+ * @param {TreeNode} root
12
+ * @return {number}
13
14
+var sumOfLeftLeaves = function (root) {
15
+ if (root === null) {
16
+ return 0;
17
+ }
18
+ if (root.left !== null && root.left.left === null && root.left.right === null) {
19
+ return root.left.val + sumOfLeftLeaves(root.right)
20
21
+ return sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right);
22
+};
0 commit comments