如果觉得对你有帮助,能否点个赞或关个注,以示鼓励笔者呢?!博客目录 | 先点这里
1.题目
题目链接:传送门(点我)
2.题解
思路如图所示
//AC代码
public class Solution {
public ListNode ReverseList(ListNode head) {
ListNode pre = null;
ListNode cur =head;
while(cur!=null){
ListNode t = cur.next;//保存下一个节点位置
cur.next=pre;
pre=cur;
cur=t;
}
return pre;
}
}