diff --git a/Count Complete Tree Nodes b/Count Complete Tree Nodes new file mode 100644 index 0000000..41442c2 --- /dev/null +++ b/Count Complete Tree Nodes @@ -0,0 +1,20 @@ +class Solution { +public: + int countNodes(TreeNode* root) { + queueq; + int ans=0; + if(root==NULL) return 0; + q.push(root); + while(!q.empty()){ + int n=q.size(); + for(int i=0;ileft!=NULL) q.push(temp->left); + if(temp->right!=NULL) q.push(temp->right); + } + } + return ans; + } +};