class Solution {
public String solution(String s, String skip, int index) {
String apb = "abcdefghijklmnopqrstuvwxyz";
StringBuilder sb = new StringBuilder();
for (int i = 0; i < apb.length(); i++) {
char idxChar = apb.charAt(i);
if (skip.indexOf(idxChar) == -1) {
sb.append(idxChar);
}
}
String tmp = sb.toString();
StringBuilder ansSb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
int tmpIndex = (tmp.indexOf(s.charAt(i)) + index) % tmp.length();
ansSb.append(tmp.charAt(tmpIndex));
}
return ansSb.toString();
}
}
Leave a comment