https://school.programmers.co.kr/learn/courses/30/lessons/155652
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
import java.util.*;
class Solution {
private static final int SIZE = 26;
public String solution(String s, String skip, int index) {
String answer = "";
Set<Character> skipAlpha = new HashSet<>();
for(int i = 0 ; i < skip.length() ; i++){
char ch = skip.charAt(i);
skipAlpha.add(ch);
}
StringBuilder sb = new StringBuilder();
for(int i = 0 ; i < s.length() ; i++){
char ch = s.charAt(i);
char next = jump(ch,index,skipAlpha);
sb.append(next);
}
answer = sb.toString();
return answer;
}
private static char jump(char ch, int index, Set<Character> skipAlpha){
while(index > 0){
ch++;
if(ch >'z'){
ch = 'a';
}
if(skipAlpha.contains(ch)){
continue;
}
index--;
}
return ch;
}
}
'알고리즘' 카테고리의 다른 글
프로그래머스 점 찍기 (JAVA) (0) | 2023.04.17 |
---|---|
프로그래머스 연속된 부분 수열의 합 (JAVA) (0) | 2023.04.16 |
프로그래머스 바탕화면 정리(JAVA) (0) | 2023.04.14 |
프로그래머스 미로 탈출 (JAVA) (0) | 2023.04.13 |
프로그래머스 시소 짝궁 (JAVA) (0) | 2023.04.12 |