Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knakul853
- **/
- class Solution {
- public:
- ListNode* reverseList(ListNode* head) {
- ListNode* pre=NULL ; ///1->2->3->4
- while(head)
- {
- ListNode* save_next = head->next;
- head->next=pre;
- pre = head;
- head = save_next;
- }
- return pre; //(o(n) and o(1))
- }
- };
Add Comment
Please, Sign In to add comment