diff options
Diffstat (limited to 'other/count_complete_tree_node.cpp')
-rw-r--r-- | other/count_complete_tree_node.cpp | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/other/count_complete_tree_node.cpp b/other/count_complete_tree_node.cpp deleted file mode 100644 index 5929110..0000000 --- a/other/count_complete_tree_node.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - int countNodes(TreeNode *root) { - if (!root) - return 0; - int l = 1, r = 1; - TreeNode *ptr_r = root, *ptr_l = root; - while (ptr_l = ptr_l->left) - l++; - while (ptr_r = ptr_r->right) - r++; - if (l == r) - return pow(2, l) - 1; - return 1 + countNodes(root->left) + countNodes(root->right); - } -}; |