题目
原题链接: https://leetcode-cn.com/problems/reverse-linked-list
分析
题解
/**
* 迭代方法
*/
class Solution {
public ListNode reverseList(ListNode head) {
if (null == head){
return null;
}
ListNode res = null;
while(head != null){
ListNode temp = head.next;
head.next = res;
res = head;
head = temp;
}
return res;
}
}