728x90
SMALL

C#

 

 

 

using System;

public class Solution {
    public string solution(string s, string skip, int index) {
        string answer = "";
        
        for(int i = 0;i<s.Length;i++)
        {
            int asc = Convert.ToInt32(s[i]);
            
            for(int k = 0;k<index;k++)
            {
                asc++;
                if(asc > 122)
                {
                    asc = asc - 26;
                }
                
                for(int j = 0;j<skip.Length;j++)
                {
                    if(skip.Contains((char)asc))
                    {
                        asc++;
                        if(asc > 122)
                        {
                            asc = asc - 26;
                        }
                    }
                }
            }
        
            answer += (char)asc;
        }
        
        return answer;
    }
}

 

 

 

////////////////

 

 

 

자바

 

 

class Solution {
    public String solution(String s, String skip, int index) {
        StringBuilder answer = new StringBuilder();

        for (char letter : s.toCharArray()) 
        {
            char temp = letter;
            int idx = 0;
            
            while (idx < index) 
            {
                temp = temp == 'z' ? 'a' : (char) (temp + 1);
                
                if (!skip.contains(String.valueOf(temp))) 
                {
                    idx += 1;
                }
            }
            answer.append(temp);
        }

        return answer.toString();
    }
}

 

 

 

class Solution {
    public String solution(String s, String skip, int index) {
        String answer = "";

        for (char c : s.toCharArray()) 
        {
            for (int i = index; i > 0; i--) 
            {
                c++;
                if (c > 122) c -= 26;
                while (skip.contains(String.valueOf(c))) 
                {
                    c++;
                    if (c > 122) c -= 26;
                }
            }
            answer += c;
        }
        return answer;
    }
}

 

 

https://m.blog.naver.com/gboarder/90015619564

 

[C#] 문자의 ASCII코드 얻는 방법

Written by Youngil Kim, C#.NET Developer   ASCII코드란 숫자, 영소대문자등에 할당된...

blog.naver.com

728x90

설정

트랙백

댓글