Recursive Java Accepted Solution


  • 0
    O
    public class Solution {
       
    
         public void deleteNode(ListNode node) {
                if(node.next==null){
                    return;
                }
                node.val = node.next.val;
                if(node.next.next==null){
                    node.next=null;
                      return;
                }
                deleteNode(node.next);
                return;
            }
    
    }

Log in to reply
 

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