C# 알고리즘 코드카타

67. 둘만의 암호

잼잼재미 2024. 1. 15. 09:48

using System;

public class Solution {
    public string solution(string s, string skip, int index) {
        string answer = "";
        int count = 0;
        char newCha;
        
        char[] cha = s.ToCharArray();
        
        for(int i = 0; i < cha.Length; ++i)
        {
            count = 0;
            newCha = cha[i];
            
            while(true)
            {
                newCha++;
                if(newCha == '{') newCha = 'a';
                
                if(skip.IndexOf(newCha) == -1) count++;
                
                if(count == index) break;
            }
            answer += newCha;
        }
        
        return answer;
    }
}

 

아스키 코드표를 참고하여 알파벳 소문자만 반복되도록 했다.

'C# 알고리즘 코드카타' 카테고리의 다른 글

69. 성격 유형 검사하기  (0) 2024.01.19
68. 햄버거 만들기  (0) 2024.01.16
66. 대충 만든 자판  (0) 2024.01.12
65. 문자열 나누기  (1) 2024.01.09
64. 체육복  (2) 2024.01.05