YJ의 새벽

프로그래머스(0) - 암호 해독 본문

코딩테스트연습/프로그래머스

프로그래머스(0) - 암호 해독

YJDawn 2024. 3. 13. 14:34

 

 

 

 

 

 

class Solution {
    public String solution(String cipher, int code) {
        String answer = "";
        
        // 시작을 code 로 잡아주고, code 만큼 += 하여 추출
        for(int i=code-1; i<cipher.length(); i+=code) {
        	answer += cipher.charAt(i);
        }
        
        return answer;
    }
}
Comments