Merge pull request #1227 from jonathanx111/patch-1

纠正0027的Swift答案
This commit is contained in:
程序员Carl
2022-05-04 17:04:38 +08:00
committed by GitHub

View File

@ -281,10 +281,8 @@ func removeElement(_ nums: inout [Int], _ val: Int) -> Int {
for fastIndex in 0..<nums.count {
if val != nums[fastIndex] {
if slowIndex != fastIndex {
nums[slowIndex] = nums[fastIndex]
}
slowIndex += 1
slowIndex += 1
}
}
return slowIndex