纠正0027的Swift答案

Swift答案写错了。改成对的答案。
This commit is contained in:
jonathanx111 2022-04-09 13:49:55 -04:00 committed by GitHub
parent eeba1786c9
commit 2e18054079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

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