mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
@ -281,10 +281,8 @@ func removeElement(_ nums: inout [Int], _ val: Int) -> Int {
|
|||||||
|
|
||||||
for fastIndex in 0..<nums.count {
|
for fastIndex in 0..<nums.count {
|
||||||
if val != nums[fastIndex] {
|
if val != nums[fastIndex] {
|
||||||
if slowIndex != fastIndex {
|
|
||||||
nums[slowIndex] = nums[fastIndex]
|
nums[slowIndex] = nums[fastIndex]
|
||||||
}
|
slowIndex += 1
|
||||||
slowIndex += 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return slowIndex
|
return slowIndex
|
||||||
|
Reference in New Issue
Block a user