一、题目
二、代码
import java.util.*;
public class Solution
{
public ListNode ReverseList (ListNode head)
{
// write code here
if(head == null) return null;
ListNode temp_1 = null;
ListNode temp_2 = null;
ListNode temp_3 = null;
temp_1 = head;
if(temp_1.next!=null)
{
temp_2 = temp_1.next;
temp_1.next = null;
}
while(temp_2!=null)
{
temp_3 = temp_2.next;
temp_2.next = temp_1;
temp_1 = temp_2;
temp_2 = temp_3;
}
return temp_1;
}
}