翻转链表(leetcode 206)

(康复训练)。。。

一来给我整迷糊了

class Solution {
    public ListNode reverseList(ListNode head) {
        if(head==null||head.next==null) return head;
        ListNode newHead = reverseList(head.next);
        head.next.next = head;
        head.next= null;
        return newHead;
    }
}

 

本文系作者 @ 原创发布在 噓だ。未经许可,禁止转载。

喜欢()
评论 (0)
热门搜索
37 文章
3 评论
11 喜欢
Top