We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5464406 commit b7f0959Copy full SHA for b7f0959
17 - Binary Tree Data Structure Problems/20 - Left View of Binary Tree/main.cpp
@@ -0,0 +1,19 @@
1
+class Solution {
2
+ private:
3
+ void solve(Node* root, vector<int> &ans, int level){
4
+ if(root == NULL) return;
5
+
6
+ if(level == ans.size()) ans.push_back(root -> data);
7
8
+ solve(root -> left, ans, level+1);
9
+ solve(root -> right, ans, level+1);
10
+ }
11
+ public:
12
+ vector<int> leftView(Node *root) {
13
+ vector<int> ans;
14
15
+ solve(root, ans, 0);
16
17
+ return ans;
18
19
+};
0 commit comments