Skip to content

Commit

Permalink
82 accepted, 15ms. The fastest is 6ms.
Browse files Browse the repository at this point in the history
  • Loading branch information
aQua authored and aQua committed Sep 6, 2017
1 parent c651843 commit a31e550
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ type ListNode struct {
}

func deleteDuplicates(head *ListNode) *ListNode {
if head == nil {
return nil
}

if head.Next != nil && head.Val == head.Next.Val {
val := head.Val
head = head.Next.Next

for head != nil && head.Val == val {
head = head.Next
}

return deleteDuplicates(head)
}

head.Next = deleteDuplicates(head.Next)

return head
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ func Test_Problem0082(t *testing.T) {

question{
para{
[]int{1, 1, 2, 2, 3, 3, 4, 4, 5},
[]int{1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8},
},
ans{
[]int{5},
[]int{5, 6, 7, 8},
},
},

Expand Down

0 comments on commit a31e550

Please sign in to comment.