Created
March 13, 2021 04:16
-
-
Save liyunrui/b10cf07686fe8f6d474880d7b563ee6c to your computer and use it in GitHub Desktop.
leetcode-LL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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