#-*- coding: UTF-8 -*-
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def removeElements(self, head, val):
"""
:type head: ListNode
:type val: int
:rtype: ListNode
"""
if head==None:return []
dummy=ListNode(-1)
dummy.next=head
p=dummy
while head:
if head.val==val:
p.next=head.next
head=p
p=head
head=head.next
return dummy.next
相关文章
- 10-05[LeetCode203]Remove Linked List Elements
- 10-05LeetCode 141. Linked List Cycle--百度面试编程题--C++,Python解法
- 10-05LeetCode--LinkedList--203. Remove Linked List Elements(Easy)
- 10-05leetcode:Remove Linked List Elements
- 10-05[LC]203题 Remove Linked List Elements (移除链表元素)(链表)
- 10-05【leetcode】Remove Linked List Elements(easy)
- 10-05452. Remove Linked List Elements【Naive】
- 10-05[leetcode]203. Remove Linked List Elements链表中删除节点
- 10-05Leetcode 203 Remove Linked List Elements 链表
- 10-05[LeetCode] 203. Remove Linked List Elements 解题思路