https://leetcode-cn.com/problems/reverse-string/
示例 1:
输入:["h","e","l","l","o"] 输出:["o","l","l","e","h"]示例 2:
输入:["H","a","n","n","a","h"] 输出:["h","a","n","n","a","H"]直接看代码就行,就是不太清楚给的示例为什么用双引号
class Solution { public void reverseString(char[] s) { for (int i = 0; i < s.length / 2; i++) { swap(s, i, s.length - 1 - i); } } private void swap(char[] s, int i, int j) { char temp = s[i]; s[i] = s[j]; s[j] = temp; } }