最近面试遇到线上coding,总结一下算法题,都是一些常见的算法题,比如字符串反转等等,在此记录一下
class Test {
public static void main(String[] args) {
String str="abcdefg";
String s = reverseFive(str);
System.out.println("s = " + s);
}
public static String reverseFive(String str){
if (Objects.isNull(str)||str.length()<=0) {
return null;
}
int start=0;
int last=str.length()-1;
char[] chars = str.toCharArray();
while (start<last) {
//交换