199周周赛
大佬编码:
class Solution {
public String restoreString(String s, int[] indices) {
int n = s.length();
char[] chars = new char[n];
for(int i = 0 ; i < n ; i++){
chars[indices[i]] = s.charAt(i);
}
return new String(chars); }
}
我的编码:
class Solution {
public String restoreString(String s, int[] indices) {
char[] chstr = s.toCharArray();
ArrayList NumList = new ArrayList();
for(int i = 0 ; i < s.length() ; i++ ){
for(int j = 0;j < s.length() ; j++ ){
if(indices[j] == i){
NumList.add(chstr[j]);
}
}
if(NumList.size()==s.length()){break;}
}
return NumList.toString().replaceAll(“[^a-z]”,””);
}
}
