# 237. Delete Node in a Linked List

{% embed url="<https://leetcode.com/problems/delete-node-in-a-linked-list/>" %}

因为只能从指定需删除的`node`访问，无法把前一个`next`拉到下一个`node`上去，只能通过改`node`本身值的方式实现`in-place`操作。

```python
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    def deleteNode(self, node):
        """
        :type node: ListNode
        :rtype: void Do not return anything, modify node in-place instead.
        """
        cur = node
        while cur.next.next:
            cur.val = cur.next.val
            cur = cur.next
        cur.val = cur.next.val
        cur.next = None
```
