Simple C++ Solution;


#1
int Solution::solve(TreeNode* A) {
    if(!A)
    return 0;
    queue<TreeNode*>q;
    q.push(A);
    int res=INT_MIN;
    while(!q.empty())
    {
        int sum=0;
        int n=q.size();
        while(n--)
        {
            TreeNode* t=q.front();;
            q.pop();
            sum+=t->val;
            if(t->left)
            q.push(t->left);
            if(t->right)
            q.push(t->right);
        }
        res=max(res,sum);
    }