Skip to content

Latest commit

 

History

History
11 lines (9 loc) · 257 Bytes

ShiftZerosSolution.md

File metadata and controls

11 lines (9 loc) · 257 Bytes

Shift Zeros Solution

Swift

func shiftZeros(in arr: [Int]) -> ([Int], Int) {
    let zeroCount = arr.filter{$0 == 0}.count
    let noZeroArr = arr.filter{$0 != 0}
    return (noZeroArr + [Int](repeating: 0, count: zeroCount), zeroCount)
}