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; + } +}; +