Simple 5 liner in java


  • 0
    D
    ListNode reverseList(ListNode head){
        if(head == null || head.next == null){
            return head;
        }
        ListNode rest = reverseList(head.next);
        head.next.next = head;
        head.next = null;
        return rest;
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.