Skip to content

Commit 738d79a

Browse files
authored
Update Solution.cpp
1 parent 6a73a2a commit 738d79a

File tree

1 file changed

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

1 file changed

+12
-2
lines changed

solution/0100-0199/0103.Binary Tree Zigzag 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>> zigzagLevelOrder(TreeNode* root) {
@@ -9,7 +18,8 @@ class Solution {
918
int size = q.size();
1019
vector<int> oneLevel(size);
1120
for (int i = 0; i < size; ++i) {
12-
TreeNode* t = q.front(); q.pop();
21+
TreeNode* t = q.front();
22+
q.pop();
1323
int idx = leftToRight ? i : (size - 1 - i);
1424
oneLevel[idx] = t->val;
1525
if (t->left) q.push(t->left);
@@ -20,4 +30,4 @@ class Solution {
2030
}
2131
return res;
2232
}
23-
};
33+
};

0 commit comments

Comments
 (0)