/*
public class ListNode {
int val;
ListNode next = null;
ListNode(int val) {
this.val = val;
}
}*/
public class Solution {
public ListNode ReverseList(ListNode head) {
if(head == null){
return head;
}
ListNode prev = null, cur = head;
while(cur.next != null){
ListNode next = cur.next;
cur.next = prev;
prev = cur;
cur = next;
}
cur.next = prev;
return cur;
}
} 


京公网安备 11010502036488号