Skip to content

Commit 0719ab7

Browse files
Андрей ФедоровАндрей Федоров
authored andcommitted
203 golang solution
1 parent 2c65a33 commit 0719ab7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

go/203-Remove-Linked-List-Element.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
func removeElements(head *ListNode, val int) *ListNode {
2+
if head == nil {
3+
return nil
4+
}
5+
6+
curr := head
7+
8+
for curr.Next != nil {
9+
if curr.Next.Val == val {
10+
curr.Next = curr.Next.Next
11+
} else {
12+
curr = curr.Next
13+
}
14+
}
15+
16+
if head.Val == val {
17+
return head.Next
18+
}
19+
20+
return head
21+
}

0 commit comments

Comments
 (0)