package com.zmz.algorithm.string;

/**
 * @author 张明泽
 * Create by 2022/5/26 11:52
 * 左旋转字符串
 * 剑指Offer58-II
 */
public class LeftRotationString {
    public static void main(String[] args) {
        String str = "abcdefg";
        int target = 2;
        String result = leftRotation(str,target);
        System.out.println(result);
    }
    public static String leftRotation(String str, int target) {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(str.substring(target,str.length()) + str.substring(0,target));
        return stringBuffer.toString();
    }
}
最后修改:2022 年 05 月 27 日 07 : 11 AM
赏杯咖啡喝 谢谢您~