둘만의 암호

- StringBuilder와 String의 차이 확인
- Set 자료구조를 사용한 효율성 증가 / contains() 메서드 사용
- contains()와 indexOf()의 차이 확인
import java.util.HashSet;
import java.util.Set;
class Solution {
public String solution(String s, String skip, int index) {
String answer = "";
StringBuilder temp = new StringBuilder();
int i, j;
Set<Character> skipSet = new HashSet<>();//skip에서 문자를 찾을때 더 빠르고 효율적임
char current;
for(i = 0; i < skip.length(); i++){
skipSet.add(skip.charAt(i));
}
for(i = 0; i < s.length(); i++)
{
current = s.charAt(i);
System.out.print("최초 문자 : " + current + " / 중간 문자 : ");
for(j = 1; j <= index; j++){
current++;
if(current > 'z'){
current = 'a';
}
while(skipSet.contains(current)){
current++;
if(current > 'z'){
current = 'a';
}
}
System.out.print(current + " ");
}
System.out.println();
temp.append(current);
}
answer = temp.toString();
return answer;
}
}