https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/
Java 代码(三个指针
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode reverseList(ListNode head) {
ListNode pre = null;
ListNode cur = head;
while(cur != null){
ListNode next = cur.next;
cur.next = pre; //指针掉头
//移动指针
pre = cur;
cur = next;
}
return pre;
}
}