package org.example.test;

/**
 * 采用双指针,首尾指针互相交换数据,直到相遇
 */
public class ReverseStringTest {
    public static void main(String[] args) {
        System.out.println(solve("abc"));
    }
    public static String solve (String str) {
        // write code here
        char[] tmp = str.toCharArray();
        int a=0;
        int b=tmp.length-1;
        for (;a<b;a++, b--){
            char t = tmp[a];
            tmp[a]=tmp[b];
            tmp[b]=t;
        }
        return new String(tmp);
    }
}