diff --git a/swift/reverse-string.swift b/swift/reverse-string.swift new file mode 100644 index 0000000..cf78cd2 --- /dev/null +++ b/swift/reverse-string.swift @@ -0,0 +1,8 @@ +class Solution { + func reverseString(_ s: inout [Character]) { + for i in 0..<(s.count / 2) { + let j = s.count - i - 1 + (s[i], s[j]) = (s[j], s[i]) + } + } +}