。゚(*´□`)゚。

코딩의 즐거움과 도전, 그리고 일상의 소소한 순간들이 어우러진 블로그

ㅋㅌ

n의 배수 번째 숫자 출력하기// .charAt(i);

quarrrter 2023. 6. 12. 00:57
class Solution {
    public String solution(String cipher, int code) {
        String answer = "";
        String[] array = new String[1];
        array[0] = cipher;
        int length = cipher.length();
        
        for(int i = code; i < length+1; i+=code) {
            answer += cipher.charAt(i-1);
        }
        
        
        return answer;
    }
}

answer += cipher.charAt(i);로 answer에 해당 인덱스 i의 문자를 추가합니다