# LeetCode-Binary Tree Level Order Traversal-解题报告

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).

For example:
Given binary tree {3,9,20,#,#,15,7},

    3
/ \
9  20
/  \
15   7


return its level order traversal as:

[
[3],
[9,20],
[15,7]
]


/**
* Definition for a binary tree node.
* struct TreeNode {
*     int val;
*     TreeNode *left;
*     TreeNode *right;
*     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<vector<int> > levelOrder(TreeNode* root) {
vector<vector<int> >ans;
queue<TreeNode*>Q;
vector<int>tmp;
if (root == NULL)return ans;
Q.push(root);
while (!Q.empty())
{
tmp.clear();
int size = Q.size();
for (int i = 0; i < size; ++i)
{
TreeNode* t = Q.front();
Q.pop();
tmp.push_back(t->val);
if (t->left != NULL)Q.push(t->left);
if (t->right != NULL)Q.push(t->right);
}
ans.push_back(tmp);
}
return ans;
}
};

#### 102. Binary Tree Level Order Traversal [easy] (Python)

2016-05-10 14:40:58

#### LeetCode102 Binary Tree Level Order Traversal Java

2016-04-23 14:20:55

#### LeetCode --- 107. Binary Tree Level Order Traversal II

2015-04-17 16:46:33

#### leetcode 之Binary Tree Level Order Traversal I和II 解题思路

2014-07-11 23:43:09

#### 【LeetCode】102. Binary Tree Level Order Traversal 解题报告

2016-05-26 15:06:54

#### LeetCode 107:Binary Tree Level Order Traversal II

2015-05-31 00:11:23

#### Binary Tree Zigzag Level Order Traversal -- LeetCode

2014-04-26 04:31:29

#### leetcode 102 Binary Tree Level Order Traversal

2015-07-14 22:53:54

#### leetcode 107 Binary Tree Level Order Traversal II C++

2016-05-28 20:57:50

#### [C++]LeetCode: 31 Binary Tree Level Order Traversal

2014-11-25 19:17:18