Description

Submission
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* reverseList(ListNode* head) { ListNode* new_head = NULL; for(ListNode* ptr = head; ptr;) { ListNode* tmp = ptr->next; ptr->next = new_head; new_head = ptr; ptr = tmp; } return new_head; } };
