题解 | #访问单个节点的删除#
访问单个节点的删除
http://www.nowcoder.com/practice/6a668a3960e24d3ea04bba89109c6451
# -*- coding:utf-8 -*-
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Remove:
def removeNode(self, pNode):
# write code here
if not pNode.next: # 尾节点直接返回False
return False
# 将此节点的值=下一个节点的值,再将下一个节点删除
pNode.val = pNode.next.val
pNode.next = pNode.next.next
return True