Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 335 Bytes

344-Reverse-String.md

File metadata and controls

19 lines (13 loc) · 335 Bytes

344. Reverse String

2017-02-25

Write a function that takes a string as input and returns the string reversed.

Example: Given s = "hello", return "olleh".

Solution

class Solution {
    func reverseString(_ s: String) -> String {
          return  s.characters.reversed().reduce("", { $0+"\($1)"})
    }
}