💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
Write a function that takes a string as input and returns the string reversed. ``` public class Solution { public String reverseString(String s) { if(s==null || s.length()==0){ return s; } int left = 0; int right = s.length()-1; char[] sChar = s.toCharArray(); while(left<right){ char temp = sChar[left]; sChar[left] = sChar[right]; sChar[right] = temp; left++; right--; } return new String(sChar); } } ```