Tree Sum of left leaves
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given a binary tree. Find the sum of all its left leaves.
Definition of a tree:
// Java class TreeNode { public: int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; left = NULL; right = NULL; };
// C++ class TreeNode { public: int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} };
Implement a function sumLeft that returns the sum of left leaves in the tree. If input tree haven't left leaves, return .
// Java int sumLeft(TreeNode tree) // C++ int sumLeft(TreeNode *tree)
Note
Function sumLeft returns .
Submissions 2K
Acceptance rate 45%