leetcode222_数完全二叉树节点

public int countNodes(TreeNode root) {
        if(root == null) return 0;
        int left = countNodes(root.left);
        int right = countNodes(root.right);
        return left + right + 1;
    }
posted @ 2022-02-16 22:29  明卿册  阅读(10)  评论(0编辑  收藏  举报