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