From 0bb79780aad714fb2a3ae04952a9cb26120a070c Mon Sep 17 00:00:00 2001 From: chayan das Date: Tue, 6 May 2025 23:56:38 +0530 Subject: [PATCH] Create 6 May Left View of Binary Tree --- 6 May Left View of Binary Tree | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 6 May Left View of Binary Tree diff --git a/6 May Left View of Binary Tree b/6 May Left View of Binary Tree new file mode 100644 index 0000000..45a6aea --- /dev/null +++ b/6 May Left View of Binary Tree @@ -0,0 +1,29 @@ +class Solution { + public: + vector leftView(Node *root) { + // code here + vector result; + if (!root) return result; + + queueq; + q.push(root); + + while(!q.empty()){ + + int n=q.size(); + Node* curr = q.front(); + result.push_back(curr->data); + + while(n--){ + Node* x = q.front(); + q.pop(); + if(x->left) + q.push(x->left); + if(x->right) + q.push(x->right); + } + } + return result; + } +}; +