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 the input tree has no left leaves, return .
// Java
int sumLeft(TreeNode tree)
// C++
int sumLeft(TreeNode *tree)
Function sumLeft returns 14 = 5 + 9.