#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
*****************************************
Author:         zhlinh
Email:          <EMAIL>
Version:        0.0.1
Created Time:   2016-03-24
Last_modify:    2016-03-24
******************************************
'''

'''
Remove all elements from a linked list of integers that have value val.

Example
Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6
Return: 1 --> 2 --> 3 --> 4 --> 5

Credits:
Special thanks to @mithmatt for adding this problem and creating all test cases.
'''

# 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
        """
        dummy = h = ListNode(0)
        dummy.next = head
        while h and h.next:
            if h.next.val == val:
                h.next = h.next.next
            else:
                h = h.next
        return dummy.next



#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
*****************************************
Author:         zhlinh
Email:          <EMAIL>
Version:        0.0.1
Created Time:   2016-03-24
Last_modify:    2016-03-24
******************************************
'''

'''
Remove all elements from a linked list of integers that have value val.

Example
Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6
Return: 1 --> 2 --> 3 --> 4 --> 5

Credits:
Special thanks to @mithmatt for adding this problem and creating all test cases.
'''

# 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
        """
        dummy = h = ListNode(0)
        dummy.next = head
        while h and h.next:
            if h.next.val == val:
                h.next = h.next.next
            else:
                h = h.next
        return dummy.next



#!/usr/bin/env python # -*- coding: utf-8 -*- ***************************************** Author:         zhlinh Email:          <EMAIL> Version:        0.0.1 Created Time:   2016-03-24 Last_modify:    2016-03-24 ****************************************** Remove all elements from a linked list of integers that have value val.  Example Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6 Return: 1 --> 2 --> 3 --> 4 --> 5  Credits: Special thanks to @mithmatt for adding this problem and creating all test cases. # Definition for singly-linked list. :type head: ListNode         :type val: int         :rtype: ListNode