We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6a73a2a commit 738d79aCopy full SHA for 738d79a
solution/0100-0199/0103.Binary Tree Zigzag Level Order Traversal/Solution.cpp
@@ -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
+ */
10
class Solution {
11
public:
12
vector<vector<int>> zigzagLevelOrder(TreeNode* root) {
@@ -9,7 +18,8 @@ class Solution {
18
int size = q.size();
19
vector<int> oneLevel(size);
20
for (int i = 0; i < size; ++i) {
- TreeNode* t = q.front(); q.pop();
21
+ TreeNode* t = q.front();
22
+ q.pop();
13
23
int idx = leftToRight ? i : (size - 1 - i);
14
24
oneLevel[idx] = t->val;
15
25
if (t->left) q.push(t->left);
@@ -20,4 +30,4 @@ class Solution {
30
}
31
return res;
32
-};
33
+};
0 commit comments