Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. class Solution {
  2. public:
  3. ListNode* reverseList(ListNode* head) {
  4. ListNode * curr = head;
  5. ListNode * prev = NULL;
  6. ListNode * temp;
  7.  
  8. while(curr != NULL){
  9. curr->next = prev;
  10. temp = prev;
  11. prev = curr;
  12. curr = curr->next;
  13. if(temp != NULL)
  14. temp->next = NULL;
  15. }
  16. return prev;
  17. }
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement