Skip to content

Instantly share code, notes, and snippets.

@liyunrui
Created March 13, 2021 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liyunrui/b10cf07686fe8f6d474880d7b563ee6c to your computer and use it in GitHub Desktop.
Save liyunrui/b10cf07686fe8f6d474880d7b563ee6c to your computer and use it in GitHub Desktop.
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