题解 | #反转链表--递归实现#
反转链表
http://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca
//TODO 递归的方式 递归就相当于栈
//1->2->3->4->5->null
// 判断边界的条件
if(head==null||head.next==null){
return head;
}
//TODO 递归的方式
//此时head.next->5
ListNode res = ReverseList(head.next);
//意思就是5.next=4
head.next.next=head;
//4<-5
//....
head.next=null;
return res;