Swift solution


  • 0
    class Solution {
        func deleteNode(_ node: inout ListNode?) {
            if node == nil || node?.next == nil {
                node = nil
                return
            }
            
            node?.val = node!.next!.val
            node?.next = node?.next?.next
        }
    }
    

Log in to reply
 

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