Skip to content

Commit 020d85a

Browse files
authored
Merge pull request gzc426#283 from GatesMa/patch-8
Create GatesMa.md
2 parents eb6d9ab + 051bba7 commit 020d85a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

2018.12.05-leetcode102/GatesMa.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# C++
2+
```cpp
3+
class Solution {
4+
public:
5+
vector<vector<int>> res;
6+
void check(TreeNode* root, int depth){
7+
if(root == NULL) return ;
8+
if(res.size() == depth)
9+
{
10+
res.push_back(vector<int>());
11+
}
12+
res[depth].push_back(root->val);
13+
check(root->left, depth + 1);
14+
check(root->right, depth + 1);
15+
}
16+
vector<vector<int>> levelOrder(TreeNode* root) {
17+
check(root, 0);
18+
return res;
19+
}
20+
};
21+
```

0 commit comments

Comments
 (0)