解题思路:使用两个指针,然后反向输出节点
public class Solution {
public ListNode ReverseList(ListNode head) {
if(head == null){
return null;
}
ListNode temp = null;
while(head != null){
ListNode p = head.next;
head.next = temp;
temp = head;
head = p;
}
return temp;
}
}