C++ right-to-left


  • 0
    S

    int findBottomLeftValue(TreeNode* root) {
    queue<TreeNode*> q;
    q.push(root);
    TreeNode* res = root;
    while (q.size() > 0)
    {
    res = q.front();
    if (res->right) q.push(res->right);
    if (res->left) q.push(res->left);
    q.pop();
    }
    return res->val;
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.