My Simple Java Recursive approach

  • 1
    public class Solution {
        public ListNode reverse(ListNode head, ListNode prev) {
            if(head == null) return prev;
            ListNode newHead = reverse(, head);
   = prev;
            return newHead;
        public ListNode reverseList(ListNode head) {
            return reverse(head, null);

Log in to reply

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