https://school.programmers.co.kr/learn/courses/30/lessons/155652
skip์ ํด๋นํ๋ ๋ฌธ์๊ฐ ์๊ณ , z๊ฐ ๋์ด๊ฐ๋ฉด a๋ก ๋์์ค๋๊ฒ๋ง ์ ๊ฒฝ์ฐ๋ฉด ๋๋ค.
class Solution {
public String solution(String s, String skip, int index) {
String answer = "";
char[] ch = s.toCharArray();
for(int i=0; i<ch.length; i++) {
for (int j = 0; j < index; j++) {
ch[i]++;
if (ch[i] > 'z') {
ch[i] -= 26;
}
while (skip.contains(String.valueOf(ch[i]))) {
ch[i]++;
if (ch[i] > 'z') {
ch[i] -= 26;
}
}
}
}
answer = String.valueOf(ch);
return answer;
}
}
'๐ ์ฝ๋ฉํ ์คํธ > ๋ฐฑ์ค & ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 2 : ์ต๋๊ฐ๊ณผ ์ต์๊ฐ (0) | 2023.03.17 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 1 : ์น์์ด (2) (0) | 2023.03.15 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 1 : [1์ฐจ]๋น๋ฐ์ง๋ (0) | 2023.03.14 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 1 : ํ๋ฒ๊ฑฐ ๋ง๋ค๊ธฐ ( *Stack ) (0) | 2023.03.09 |
[ํ๋ก๊ทธ๋๋จธ์ค][JAVA]Level 1 : ๊ธฐ์ฌ๋จ์์ ๋ฌด๊ธฐ (*์ฝ์) (0) | 2023.03.08 |