Python, LintCode, 372. Delete Node in a Linked List

"""
Definition of ListNode
class ListNode(object):

    def __init__(self, val, next=None):
        self.val = val
        self.next = next
"""


class Solution:
    """
    @param: node: the node in the list should be deletedt
    @return: nothing
    """
    def deleteNode(self, node):
        # write your code here
        node.val = node.next.val
        node.next = node.next.next
        return

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页