File tree 1 file changed +16
-15
lines changed
scripts/algorithms/C/Count Complete Tree Nodes
1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change
1
+ // Runtime: 0 ms (Top 100.00%) | Memory: 50.7 MB (Top 10.84%)
1
2
/**
2
3
* Definition for a binary tree node.
3
4
* public class TreeNode {
4
- * int val;
5
- * TreeNode left;
6
- * TreeNode right;
7
- * TreeNode() {}
8
- * TreeNode(int val) { this.val = val; }
9
- * TreeNode(int val, TreeNode left, TreeNode right) {
10
- * this.val = val;
11
- * this.left = left;
12
- * this.right = right;
13
- * }
5
+ * int val;
6
+ * TreeNode left;
7
+ * TreeNode right;
8
+ * TreeNode() {}
9
+ * TreeNode(int val) { this.val = val; }
10
+ * TreeNode(int val, TreeNode left, TreeNode right) {
11
+ * this.val = val;
12
+ * this.left = left;
13
+ * this.right = right;
14
+ * }
14
15
* }
15
16
*/
16
17
class Solution {
17
-
18
- static int count = 0 ;
19
-
18
+
19
+ static int count = 0 ;
20
+
20
21
static void Postorder (TreeNode root ){
21
22
if (root == null ){
22
23
return ;
@@ -25,10 +26,10 @@ static void Postorder(TreeNode root){
25
26
Postorder (root .right );
26
27
count ++;
27
28
}
28
-
29
+
29
30
public int countNodes (TreeNode root ) {
30
31
count = 0 ;
31
32
Postorder (root );
32
33
return count ;
33
34
}
34
- }
35
+ }
You can’t perform that action at this time.
0 commit comments