Skip to content

Commit 5770d11

Browse files
committed
Update 0027 solution
1 parent 4384f0d commit 5770d11

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

leetcode/0027.Remove-Element/27. Remove Element.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ func removeElement(nums []int, val int) int {
99
if nums[i] != val {
1010
if i != j {
1111
nums[i], nums[j] = nums[j], nums[i]
12-
j++
13-
} else {
14-
j++
1512
}
13+
j++
1614
}
1715
}
1816
return j

website/content/ChapterFour/0027.Remove-Element.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ func removeElement(nums []int, val int) int {
8080
if nums[i] != val {
8181
if i != j {
8282
nums[i], nums[j] = nums[j], nums[i]
83-
j++
84-
} else {
85-
j++
8683
}
84+
j++
8785
}
8886
}
8987
return j

0 commit comments

Comments
 (0)