Skip to content

Commit 37fab7c

Browse files
Create 0283-Move-Zeroes.Swift
1 parent 2b1ef04 commit 37fab7c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

swift/0283-Move-Zeroes.Swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
func moveZeroes(_ nums: inout [Int]) {
3+
var index: Int = 0
4+
5+
for num in nums where num != 0 {
6+
nums[index] = num
7+
index += 1
8+
}
9+
10+
for i in index..<nums.count {
11+
nums[i] = 0
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)