1020. Tree Traversals (25)
本文共 947 字,大约阅读时间需要 3 分钟。
1020. Tree Traversals (25)
#include #include #include #include #include #include #include #include #include
ans; queue
q; if(p) q.push(p); while (!q.empty()) { p = q.front(); q.pop(); ans.push_back(p->val); if(p->left) q.push(p->left); if(p->right) q.push(p->right); } for (int i=0; i