Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- ListNode* reverseList(ListNode* head) {
- ListNode * curr = head;
- ListNode * prev = NULL;
- ListNode * temp;
- while(curr != NULL){
- curr->next = prev;
- temp = prev;
- prev = curr;
- curr = curr->next;
- if(temp != NULL)
- temp->next = NULL;
- }
- return prev;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement