第21072题 单选题
以下C++代码实现二叉树广度优先搜索(BFS)查找目标节点,横线处应填入的代码是?
TreeNode* findNode(TreeNode* root, int target) {
  if (root == nullptr) return nullptr;

  queue<TreeNode*> q;
  q.push(root);
  while (!q.empty()) {
    TreeNode* current = q.front();
    q.pop();

    if (current->val == target) {
      return current; // 找到目标节点
    }

    ________________________ // 在此处填入代码
  }
  return nullptr; // 未找到目标节点
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析