|
|
@ -17,9 +17,9 @@ vector<int> hierOrder(TreeNode* root) {
|
|
|
|
TreeNode* node = queue.front();
|
|
|
|
TreeNode* node = queue.front();
|
|
|
|
queue.pop(); // 队列出队
|
|
|
|
queue.pop(); // 队列出队
|
|
|
|
vec.push_back(node->val); // 保存结点
|
|
|
|
vec.push_back(node->val); // 保存结点
|
|
|
|
if (node->left != NULL)
|
|
|
|
if (node->left != nullptr)
|
|
|
|
queue.push(node->left); // 左子结点入队
|
|
|
|
queue.push(node->left); // 左子结点入队
|
|
|
|
if (node->right != NULL)
|
|
|
|
if (node->right != nullptr)
|
|
|
|
queue.push(node->right); // 右子结点入队
|
|
|
|
queue.push(node->right); // 右子结点入队
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return vec;
|
|
|
|
return vec;
|
|
|
|