Skip to content

Commit

Permalink
Create 0283-Move-Zeroes.Swift
Browse files Browse the repository at this point in the history
  • Loading branch information
kabirdhillon7 authored Jan 7, 2023
1 parent 2b1ef04 commit 37fab7c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions swift/0283-Move-Zeroes.Swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
func moveZeroes(_ nums: inout [Int]) {
var index: Int = 0

for num in nums where num != 0 {
nums[index] = num
index += 1
}

for i in index..<nums.count {
nums[i] = 0
}
}
}

0 comments on commit 37fab7c

Please sign in to comment.