[Leetcode 206/92] Reverse Linked List I/II

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

ListNode* reverseList(ListNode* head) { //=== passed OJ
if( head == NULL ) return head;
ListNode* i = head->next;
head->next = NULL; //=== easy to miss this line of code
while( i != NULL ) {
ListNode* future = i->next;
i->next = head;
head = i;
i = future;
}
return head;
}

jamesqiu
Автор

II的解法好像不对吧,题目明确要求one pass。两个for loop循环已经不是one pass了

jonfit
Автор

第二部分,5分40多秒那儿为什么m node 插到n node 的后面,然后又说m node和n node重合?到底在后面还是重合啊

glaiveEdits
join shbcf.ru