Skip to content

Commit 5106bb0

Browse files
authored
Update Solution.cpp
1 parent de6954e commit 5106bb0

File tree

1 file changed

+12
-2
lines changed
  • solution/0100-0199/0102.Binary Tree Level Order Traversal

1 file changed

+12
-2
lines changed

solution/0100-0199/0102.Binary Tree Level Order Traversal/Solution.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* struct TreeNode {
4+
* int val;
5+
* TreeNode *left;
6+
* TreeNode *right;
7+
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
8+
* };
9+
*/
110
class Solution {
211
public:
312
vector<vector<int>> levelOrder(TreeNode* root) {
@@ -7,7 +16,8 @@ class Solution {
716
while (!q.empty()) {
817
vector<int> oneLevel;
918
for (int i = q.size(); i > 0; --i) {
10-
TreeNode* t = q.front(); q.pop();
19+
TreeNode* t = q.front();
20+
q.pop();
1121
oneLevel.push_back(t->val);
1222
if (t->left) q.push(t->left);
1323
if (t->right) q.push(t->right);
@@ -16,4 +26,4 @@ class Solution {
1626
}
1727
return res;
1828
}
19-
};
29+
};

0 commit comments

Comments
 (0)