1、 反转单链表 使用双指针
leetcode-cn.com/problems/fa…
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode reverseList(ListNode head) {
if(head==null){
return null;
}
ListNode cur=null,pre= head;
while(pre!=null){
ListNode t = pre.next;
pre.next = cur;
cur = pre;
pre=t;
}
return cur;
}
}