From 26ffc0327cc1d6347a2f57dd44e497035bc7dad3 Mon Sep 17 00:00:00 2001 From: Gaurav Gupta Date: Fri, 31 Oct 2025 19:12:28 +0530 Subject: [PATCH] Count Complete Tree Nodes --- Count Complete Tree Nodes | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Count Complete Tree Nodes 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; + } +};