mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-09 15:59:06 +01:00
swift: add «344. Reverse String»
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
5307e7ef85
commit
81e5186b71
1 changed files with 8 additions and 0 deletions
8
swift/reverse-string.swift
Normal file
8
swift/reverse-string.swift
Normal 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])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue