Untitled
unknown
plain_text
2 years ago
330 B
23
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