Advertisement
MohammedShoaib

222. Count Complete Tree Nodes

Jun 25th, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. /*
  2. Problem Statement: https://leetcode.com/problems/count-complete-tree-nodes/
  3. */
  4.  
  5. class Solution {
  6. public:
  7. int countNodes(TreeNode* root) {
  8. if (!root)
  9. return 0;
  10. else
  11. return 1 + countNodes(root->left) + countNodes(root->right);
  12. }
  13. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement