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;
}
}
아스키 코드표를 참고하여 알파벳 소문자만 반복되도록 했다.