File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 3
3
import com .fishercoder .common .classes .TreeNode ;
4
4
5
5
/**
6
+ * 222. Count Complete Tree Nodes
7
+ *
6
8
* Given a complete binary tree, count the number of nodes.
7
- * <p>
9
+ *
8
10
* Definition of a complete binary tree from Wikipedia:
9
11
* In a complete binary tree every level,
10
12
* except possibly the last, is completely filled,
13
15
*/
14
16
public class _222 {
15
17
16
- class Solution1 {
18
+ class SolutionRecursive {
17
19
/**reference: https://discuss.leetcode.com/topic/21317/accepted-easy-understand-java-solution/2*/
18
20
public int countNodes (TreeNode root ) {
19
21
int leftH = getLeftHeight (root );
@@ -39,11 +41,14 @@ private int getLeftHeight(TreeNode root) {
39
41
}
40
42
return height ;
41
43
}
42
-
43
44
}
44
45
45
46
public static void main (String ...args ) {
46
47
System .out .println (1 << 3 );
47
48
}
48
49
50
+ class SolutionIterative {
51
+ /**TODO: implement an iterative solution*/
52
+ }
53
+
49
54
}
You can’t perform that action at this time.
0 commit comments