Leetcode 分享筆記

237. Delete Node in a Linked List

題目

leetcode
b

python


class Solution(object):
    def deleteNode(self, node):
        """
        :type node: ListNode
        :rtype: void Do not return anything, modify node in-place instead.
        """
        node.val = node.next.val # Node Value等於Node的下一個Node的Value
        node.next = node.next.next # Node.next 請指向Node.next.next (Node的下一個節點請指向下下個節點)