LeetCode – Count Complete Tree Nodes (Java)

Given a complete binary tree, count the number of nodes. The solution to this problem can be as simple as the following: public int countNodes(TreeNode root) { if(root == null){ return 0; }   return 1 + countNodes(root.left) + countNodes(root.right); }public int countNodes(TreeNode root) { if(root == null){ return 0; } return 1 + countNodes(root.left) … Read more