Uncategorized

[알고리즘] 시저 암호

class Solution {
    char[] upperAlpabatArr;
    char[] lowerAlpabatArr;
    
    public String solution(String s, int n) {
        int count=0;
        char c = 'a';  
        while('a'<=c&& c<='z') {
            c++;
            count++;
        }
        
        String returnStr = "";
        for(char charStr : s.toCharArray()) {
            if('a'<=charStr && charStr <='z') {
                returnStr+=(char)('a'+((charStr-'a'+n)%count));
                continue;
            }
            if('A'<=charStr && charStr <='Z') {
                returnStr+=(char)('A'+((charStr-'A'+n)%count));
                continue;
            } 
            returnStr+=" ";
        }
        
        return returnStr;
        
    }
}
https://github.com/imkim1893/algorithms/blob/master/%EC%8B%9C%EC%A0%80%EC%95%94%ED%98%B8.java