左旋转字符串
代码实现
package 剑指offer;
import java.util.Scanner;
/**
* @author WangXiaoeZhe
* @Date: Created in 2019/11/22 16:41
* @description:
*/
public class Main11 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
int n = sc.nextInt();
LeftRotateString(s, n);
}
public static String LeftRotateString(String str, int n) {
if (str == null || n > str.length() || str.length() == 0) {
return "";
}
StringBuilder sb = new StringBuilder(str);
StringBuilder sb1=new StringBuilder(str);
sb.append(sb1);
return sb.toString().substring(n, n + str.length());
}
}