Untitled

 avatar
unknown
plain_text
9 months ago
330 B
6
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