1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-16 16:36:56 +02:00

swift: add «344. Reverse String»

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-06-02 10:50:48 +02:00
parent 5307e7ef85
commit 81e5186b71
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

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