https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii


Runtime: 4 ms, faster than 92.23% of Go online submissions for Remove Duplicates from Sorted List II.
Memory Usage: 3.9 MB, less than 7.77% of Go online submissions for Remove Duplicates from Sorted List II.


```go
//type ListNode struct {
//	Val  int
//	Next *ListNode
//}

func does_this_value_in_list(value int, list []int) bool {
	for _, n := range list {
		if n == value {
			return true
		}
	}
	return false
}

func deleteDuplicates(head *ListNode) *ListNode {
	//6:45
	if head == nil {
		return nil
	}

	node_list := make([]*ListNode, 0)
	value_list := make([]int, 0)
	duplicates := make([]int, 0)

	node := head
	for node != nil {
		node_list = append(node_list, node)
		if does_this_value_in_list(node.Val, value_list) {
			duplicates = append(duplicates, node.Val)
		} else {
			value_list = append(value_list, node.Val)
		}
		node = node.Next
	}

	new_node_list := make([]*ListNode, 0)
	for _, node := range node_list {
		if !does_this_value_in_list(node.Val, duplicates) {
			new_node_list = append(new_node_list, node)
		}
	}

	for index, node := range new_node_list {
		if index != len(new_node_list)-1 {
			node.Next = new_node_list[index+1]
		} else {
			node.Next = nil
		}
	}

	if len(new_node_list) == 0 {
		return nil
	} else {
		return new_node_list[0]
	}
	//6:51
}
```