class Solution {
public:
vector<int> res;
void bfs(TreeNode* root)
{
queue<TreeNode*> q;
q.push(root);
while(q.size ())
{
auto p=q.front();
q.pop();
res.push_back(p->val);
if(p->left) q.push(p->left);
if(p->right) q.push(p->right);
}
}
vector<int> printFromTopToBottom(TreeNode* root) {
if(!root) return res;
bfs(root);
return res;
}
};
标签:right,return,分行,打印,二叉树,res,push,root
From: https://www.cnblogs.com/tangxibomb/p/17275142.html