class Solution {
public ListNode reverseList(ListNode head) {
ListNode current = head;
ListNode pre = null;
ListNode newHead = null;
while(current != null){
ListNode next = current.next;
if (next == null) {
newHead = current;
}
current.next = pre;
pre = current;
current = next;
}
return newHead;
}
}
网友评论