Untitled
Anonymous
plain_text
09/15/2024 5:29 PM
440 B
28
Indexable
class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode *temp = nullptr, *prev = nullptr;
while(head)
{
temp = head->next;
head->next = prev;
prev = head;
head = temp;
}
return prev;
}
};Editor is loading...
Leave a Comment