knakul853

Untitled

Jun 15th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. /**
  2.  knakul853
  3.  **/
  4. class Solution {
  5. public:
  6.     ListNode* reverseList(ListNode* head) {
  7.        
  8.         ListNode* pre = NULL;
  9.        
  10.         while( head )
  11.         {
  12.             ListNode* save_next = head->next;
  13.             head->next = pre;
  14.             pre = head;
  15.             head  = save_next;
  16.         }
  17.        
  18.         return pre;
  19.     }
  20. };
Add Comment
Please, Sign In to add comment