第21220题 单选题
反转单链表的给定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 }}%
答案解析