Topic description
Input a linked list, after reversing the linked list, output all elements of the linked list.
/* struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { } };*/ class Solution { public: ListNode* ReverseList(ListNode* pHead) { ListNode* head = pHead; ListNode * p1 = pHead; ListNode * p2 = pHead; head = NULL; while(p1){ p2 = p1->next; p1->next = head; head = p1; p1=p2; } return head; } };