LeetCode/swift/reverse-string.swift

9 lines
197 B
Swift
Raw Normal View History

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])
}
}
}