We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent de6954e commit 5106bb0Copy full SHA for 5106bb0
solution/0100-0199/0102.Binary Tree 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>> levelOrder(TreeNode* root) {
@@ -7,7 +16,8 @@ class Solution {
16
while (!q.empty()) {
17
vector<int> oneLevel;
18
for (int i = q.size(); i > 0; --i) {
- TreeNode* t = q.front(); q.pop();
19
+ TreeNode* t = q.front();
20
+ q.pop();
21
oneLevel.push_back(t->val);
22
if (t->left) q.push(t->left);
13
23
if (t->right) q.push(t->right);
@@ -16,4 +26,4 @@ class Solution {
26
}
27
return res;
28
-};
29
+};
0 commit comments