LeetCode 237 – Python 3 (Week 06 – 06)

Solution 1

class Solution:
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

Time and space complexity are both O(1).

Leave a comment

Design a site like this with WordPress.com
Get started