Solution 1: easy
public class Solution {
public ListNode reverseList(ListNode head) {
ListNode i=head, j=null;
while (i!=null) {
ListNode next=i.next;
i.next=j;
j=i;
i=next;
}
return j;
}
}
没有评论:
发表评论