第21297题 单选题
下列C++实现单链表反转的代码存在错误,需进行哪项修改可正确实现功能?
ListNode* reverseLinkedList(ListNode* head) {
  ListNode* prev = nullptr;
  ListNode* current = head;
  while (current != nullptr) {
    ListNode* next = current->next;
    current->next = next;
    prev = current;
    current = next;
  }
  return prev;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析