https://leetcode.com/problems/binary-tree-level-order-traversal/
class Solution {
public:
vector<vector<int>> levelOrder(TreeNode* root) {
vector<vector<int> > ret;
if(root == NULL)
return ret;
queue<TreeNode *> Q;
Q.push(root);
while(!Q.empty()) {
vector<int> sublist;
int levelNum = Q.size();
for (int i = 0; i < levelNum; i++) {
TreeNode *cur = Q.front();
if (cur->left != NULL)
Q.push(cur->left);
if (cur->right != NULL)
Q.push(cur->right)
sublist.push_back(cur->val);
Q.pop();
}
ret.push_back(sublist);
}
return ret;
}
};