topic
Problem-solving results
Problem-solving ideas: the first interpolation method
Create an empty list, the first interpolation by inserting
Problem-solving Code
class Solution {
public ListNode reverseList(ListNode head) {
ListNode pre = null;
ListNode cur = head;
while(cur != null){
// tempnode.next = head;
// tempnode = head; //尾插法
ListNode nextTemp = cur.next;
cur.next = pre;
pre = cur;//头插法
cur = nextTemp;
}
return pre;
}
}