|
4 | 4 |
|
5 | 5 | /**
|
6 | 6 | * 222. Count Complete Tree Nodes
|
7 |
| - * |
8 | 7 | * Given a complete binary tree, count the number of nodes.
|
9 |
| - * |
10 | 8 | * Definition of a complete binary tree from Wikipedia:
|
11 | 9 | * In a complete binary tree every level,
|
12 | 10 | * except possibly the last, is completely filled,
|
|
15 | 13 | */
|
16 | 14 | publicclass_222 {
|
17 | 15 |
|
18 |
| -classSolutionRecursive { |
19 |
| -/**reference: https://discuss.leetcode.com/topic/21317/accepted-easy-understand-java-solution/2*/ |
| 16 | +publicstaticclassSolution1 { |
| 17 | +/** |
| 18 | + * reference: https://discuss.leetcode.com/topic/21317/accepted-easy-understand-java-solution/2 |
| 19 | + */ |
20 | 20 | publicintcountNodes(TreeNoderoot) {
|
21 | 21 | intleftH =getLeftHeight(root);
|
22 | 22 | intrightH =getRightHeight(root);
|
@@ -46,12 +46,4 @@ private int getLeftHeight(TreeNode root) {
|
46 | 46 | }
|
47 | 47 | }
|
48 | 48 |
|
49 |
| -publicstaticvoidmain(String...args) { |
50 |
| -System.out.println(1 <<3); |
51 |
| - } |
52 |
| - |
53 |
| -classSolutionIterative { |
54 |
| -/**TODO: implement an iterative solution*/ |
55 |
| - } |
56 |
| - |
57 | 49 | }
|