LaneYang
1/12/2020 - 1:19 AM

Count Node.java

public class Solution {
    public int countNodes(TreeNode root) {
      // base case 
      if(root == null){
          return 0;
      }
      int leftCount = countNodes(root.left);
      int rightCount = countNodes(root.right);
      return 1+leftCount+rightCount;
    }
  }