먼저, Console 로그를 사용해 'a'와 'z'의 아스키 코드를 출력해 보았다.
그다음으로, skip 배열을 문자열이 아닌 아스키 코드 값들을 담은 int 배열로 변환했다.
이후, 문자열 s를 순회하며 index만큼 증가시키되, skip에 포함된 문자라면 추가로 건너뛸 수 있도록 구현했다
using System;
using System.Linq;
public class Solution {
public string solution(string s, string skip, int index)
{
int[] charSkip = skip.Select(element => (int)element).ToArray();
//Console.WriteLine("a :"+(int)'a');
//Console.WriteLine("z :"+(int)'z');
string temp = "";
for(int i = 0; i < s.Length; i++)
{
int AsCode = (int)s[i];
for(int j = 0; j < index; j++)
{
if(++AsCode > (int)'z') AsCode = (int)'a';
if(charSkip.Contains(AsCode)) j--;
}
temp += (char)AsCode;
}
return temp;
}
}
'문제 풀기 > C#' 카테고리의 다른 글
69. 성격 유형 검사하기 (0) | 2025.02.19 |
---|---|
68. 햄버거 만들기 (SequenceEqual) (0) | 2025.02.19 |
66. 대충 만든 자판(Dictionary) (0) | 2025.02.18 |
65. 문자열 나누기 (0) | 2025.02.12 |
64. 체육복 (0) | 2025.02.12 |