这道题出的也是很巧妙的,一开始我也以为少给了参数,一个不留神看到了java的答案。细细一想果然很有道理。给了很多启发。
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
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.next = node.next.next