프로그래머스 - 외계행성의 나이

차관호·2023년 3월 11일
0

문제링크 - 프로그래머스 - 외계행성의 나이


import java.util.*;
class Solution {
    public String solution(int age) {
        HashMap<String, String> codes = new HashMap<String, String>();
        String answer = "";
        
        codes.put("0","a");
        codes.put("1","b");
        codes.put("2","c");
        codes.put("3","d");
        codes.put("4","e");
        codes.put("5","f");
        codes.put("6","g");
        codes.put("7","h");
        codes.put("8","i");
        codes.put("9","j");
        
        String[] age1 = String.valueOf(age).split("");
     
        for(int i=0; i<=age1.length-1;i++){
            answer += codes.get(age1[i])+"";
        }
        
        return answer;
    }
}
profile
안녕하세요 :-)

0개의 댓글