Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
leetcode-LL
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
"""
PC:
-we're not allowed to access head of linked list
-the node to be delted won't be the tail node
So, the node to be deleted must be in the 0,1,2,..,n-1
"""
def deleteNode(self, node):
"""
:type node: ListNode
:rtype: void Do not return anything, modify node in-place instead.
"""
node.val = node.next.val
node.next= node.next.next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment