mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-13 23:40:35 +08:00
Update 0027 solution
This commit is contained in:
@ -9,10 +9,8 @@ func removeElement(nums []int, val int) int {
|
|||||||
if nums[i] != val {
|
if nums[i] != val {
|
||||||
if i != j {
|
if i != j {
|
||||||
nums[i], nums[j] = nums[j], nums[i]
|
nums[i], nums[j] = nums[j], nums[i]
|
||||||
j++
|
|
||||||
} else {
|
|
||||||
j++
|
|
||||||
}
|
}
|
||||||
|
j++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return j
|
return j
|
||||||
|
@ -80,10 +80,8 @@ func removeElement(nums []int, val int) int {
|
|||||||
if nums[i] != val {
|
if nums[i] != val {
|
||||||
if i != j {
|
if i != j {
|
||||||
nums[i], nums[j] = nums[j], nums[i]
|
nums[i], nums[j] = nums[j], nums[i]
|
||||||
j++
|
|
||||||
} else {
|
|
||||||
j++
|
|
||||||
}
|
}
|
||||||
|
j++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return j
|
return j
|
||||||
|
Reference in New Issue
Block a user