判断题 偏易
#19800

以下代码能够正确统计二叉树中叶子结点的数量。 int countLeaf ( TreeNode * root ) { if ( ! root ) return…

以下代码能够正确统计二叉树中叶子结点的数量。

int countLeaf(TreeNode* root) {
    if (!root) 
        return 0;
    if (!root->left && !root->right) 
        return 1;
    return countLeaf(root->left) + countLeaf(root->right);
}
未登录也能判分,登录后才会记录
答案与解析
正确答案:对
这道题暂未补解析。