public class Solution { public ListNode ReverseList(ListNode head) { ListNode qHead=null;//翻转后的头结点 if(head==null || head.next == null){ return head; } ListNode p = head; while (p!=null){ ListNode nextNode = p.next;//暂存 p.next = qHead; qHead = p; p = nextNode; } return qHead; } }
原文:https://www.cnblogs.com/q-1993/p/10545904.html