题目:
Write a function that reverses a string. The input string is given as an array of characters s.
写一个反转字符串的函数。输入字符串以字符数组的形式给出。
Example 1:
Input: s = [“h”,“e”,“l”,“l”,“o”]
Output: [“o”,“l”,“l”,“e”,“h”]
示例 1:
输入:[“h”,“e”,“l”,“l”,“o”]
输出:[“o”,“l”,“l”,“e”,“h”]
Example 2:
Input: s = [“H”,“a”,“n”,“n”,“a”,“h”]
Output: [“h”,“a”,“n”,“n”,“a”,“H”]
示例 2:
输入:[“H”,“a”,“n”,“n”,“a”,“h”]
输出:[“h”,“a”,“n”,“n”,“a”,“H”]
Constraints:
1 <= s.length <= 1 0 5 10^5 105
s[i] is a printable ascii character.
提示:
1 <= s.length <= 1 0 5 10^5