230913 둘만의 암호

Jongleee·2023년 9월 13일
0

TIL

목록 보기
363/576
public String solution(String s, String skip, int index) {
	StringBuilder answerBuilder = new StringBuilder();

	for (int i = 0; i < s.length(); i++) {
		char c = s.charAt(i);
		int j = 0;
		while (j < index) {
			c += 1;
			if (c > 'z') {
				c -= 26;
			}
			if (skip.contains(String.valueOf(c))) {
				j--;
			}
			j++;
		}
		answerBuilder.append(c);
	}

	return answerBuilder.toString();
}

출처:https://school.programmers.co.kr/learn/courses/30/lessons/155652

0개의 댓글