问题
实现" t Jack is name my hello" 反转为"hello my name is Jack t"
空间复杂度为O(1)
实现
思路
先将句子整体反转,即变为:“olleh ym eman si kcaJ t”
再遍历里面每个单词进行再次反转
代码
package arithmetic;
/**
* 实现英文句子反转,单词不反转,空间复杂度为O(1)
*/
public class SentRever {
public static void reverse(int first,int last,char[] chars){
int index = (last+first)/2;//中间那个
while(first<=index){
if(chars[first] == chars[last]){