* struct TreeNode {
 *	int val;
 *	struct TreeNode *left;
 *	struct TreeNode *right;
 * };
 */

class Solution {
public:
    /**
     * 
     * @param root TreeNode类 
     * @return int整型vector<vector<>>
     */
    vector<vector<int>>  res;
    vector<int> tmp;
    vector<vector<int> > levelOrder(TreeNode* root) {
        // write code here
        if(!root) return res;
        queue<TreeNode*> q;
        q.push(root);
        q.push(NULL);
        while(q.size()){
            auto t = q.front();
            q.pop();
            
            if(t){
                tmp.push_back(t->val);
                if(t->left) q.push(t->left);
                if(t->right) q.push(t->right);
            }else{
                res.push_back(tmp);
                tmp.clear();
                if(q.size()) q.push(NULL);
                
            }
        }
        return res;
    }
};