受以前某道题的启发,来了个这玩意:
str = abcXYZ
str+str = abc+XYZabc+XYZ
中间那段不就是我想要的吗
public class Solution { public String LeftRotateString(String str,int n) { if(str==null||str.length()==0 ) return ""; str = str+str; return str.substring(n,n+str.length()/2); } }
受以前某道题的启发,来了个这玩意:
str = abcXYZ
str+str = abc+XYZabc+XYZ
中间那段不就是我想要的吗
public class Solution { public String LeftRotateString(String str,int n) { if(str==null||str.length()==0 ) return ""; str = str+str; return str.substring(n,n+str.length()/2); } }