2022-05-18
Description
Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]Input: s = ["H","a","n","n","a","h"]
Output: ["h","a","n","n","a","H"]Solution
func reverseString(s []byte) {
for i, j := 0, len(s)-1; i < j; {
s[i], s[j] = s[j], s[i]
i++
j--
}
}Description
Solution
Approach #0
Approach #1
Last updated