/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int sumOfLeftLeaves(TreeNode* root) {
if (root){
if (root->left){
if (root->left->left == NULL && root->left->right == NULL){//叶子结点
if (root->right) return root->left->val + sumOfLeftLeaves(root->right);
else return root->left->val;
}
return sumOfLeftLeaves(root->left) + sumOfLeftLeaves(root->right);
}
else return sumOfLeftLeaves(root->right);
}
return 0;
}
};