/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
int result = 0;
void find_tree(TreeNode* cur , int left_flag)
{
if(cur==nullptr) return;
if(cur->left==nullptr&&cur->right==nullptr&&left_flag==1)
result += cur->val;
find_tree(cur->left,1);
find_tree(cur->right,0);
return;
}
int sumOfLeftLeaves(TreeNode* root) {
if(root == nullptr) return 0;
find_tree(root,0);
return result;
}
};