/**
* 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 ans;
void dfs(TreeNode * root,int l){
if(root == NULL) return;
if(root->left == NULL && root->right == NULL){
if(l == 1) ans += root->val;
return ;
}
dfs(root->left,1);
dfs(root->right,0);
}
int sumOfLeftLeaves(TreeNode* root) {
ans = 0;
dfs(root,0);
return ans;
}
};