private static void Helper(LeetCode222TreeNode root) { if (root == null) { return; } _count++; Helper(root.left); Helper(root.right); }
public static int CountNodes(LeetCode222TreeNode root) { Helper(root); return(_count); }
public LeetCode222TreeNode(int val = 0, LeetCode222TreeNode left = null, LeetCode222TreeNode right = null) { this.val = val; this.left = left; this.right = right; }