LeetCode222. 完全二叉树的节点个数

题目

代码

 1 class Solution {
 2 public:
 3     int dfs(TreeNode* root){
 4         if(root == NULL) return 0;
 5         int left = dfs(root->left);  //
 6         int right = dfs(root->right); //
 7         return left + right + 1; //
 8     }
 9     int countNodes(TreeNode* root) {
10         return dfs(root);
11     }
12 };
原文地址:https://www.cnblogs.com/fresh-coder/p/14507175.html