8:40 -8:53
str.length() 字符串的length 需要加 () 才可以
public class Solution {
public String LeftRotateString(String str,int n) {
char[] chars = str.toCharArray();
char[] res = new char[str.length()];
int j =n;
for (int i=0; i < str.length(); i++,j++){
if( j > str.length()-1){ j = 0;}
res[i] = chars[j];
}
return new String(res);
}
}


京公网安备 11010502036488号