递归翻转单链表

1 public ListNode reverseList(ListNode head) {
2     if (head == null || head.next == null) return head;
3     ListNode p = reverseList(head.next);
4     head.next.next = head;
5     head.next = null;
6     return p;
7 }
 

猜你喜欢

转载自www.cnblogs.com/zouma/p/10902728.html
今日推荐