美文网首页
lintcode 372. Delete Node in a L

lintcode 372. Delete Node in a L

作者: cuizixin | 来源:发表于2018-09-07 01:43 被阅读13次

    难度:容易

    1. Description

    372. Delete Node in a Linked List

    2. Solution

    • python
    """
    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
    

    3. Reference

    1. https://www.lintcode.com/problem/delete-node-in-a-linked-list/description?_from=ladder

    相关文章

      网友评论

          本文标题:lintcode 372. Delete Node in a L

          本文链接:https://www.haomeiwen.com/subject/qlkqgftx.html