Skip to content

Commit

Permalink
Merge pull request neetcode-gh#1932 from kabirdhillon7/283Swift
Browse files Browse the repository at this point in the history
Create 0283-Move-Zeroes.Swift
  • Loading branch information
tahsintunan authored Jan 7, 2023
2 parents 091497b + 37fab7c commit 66f910e
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 66f910e

Please sign in to comment.