leetcode222-完全二叉树的节点个数
作者:互联网
- 递归
class Solution {
public int countNodes(TreeNode root) {
if(root == null) return 0;
return countNodes(root.left)+countNodes(root.right)+1;
}
}
标签:return,leetcode222,个数,二叉树,countNodes,root,节点 来源: https://www.cnblogs.com/xzh-yyds/p/16625529.html