Deep_Dev
article thumbnail

๋ฌธ์ œ ์„ค๋ช…

์šฐ์ฃผ์—ฌํ–‰์„ ํ•˜๋˜ ๋จธ์“ฑ์ด๋Š” ์—”์ง„ ๊ณ ์žฅ์œผ๋กœ PROGRAMMERS-962 ํ–‰์„ฑ์— ๋ถˆ์‹œ์ฐฉํ•˜๊ฒŒ ๋์Šต๋‹ˆ๋‹ค. ์ž…๊ตญ์‹ฌ์‚ฌ์—์„œ ๋‚˜์ด๋ฅผ ๋งํ•ด์•ผ ํ•˜๋Š”๋ฐ, PROGRAMMERS-962 ํ–‰์„ฑ์—์„œ๋Š” ๋‚˜์ด๋ฅผ ์•ŒํŒŒ๋ฒณ์œผ๋กœ ๋งํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. a๋Š” 0, b๋Š” 1, c๋Š” 2, ..., j๋Š” 9์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด 23์‚ด์€ cd, 51์‚ด์€ fb๋กœ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค. ๋‚˜์ด age๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ PROGRAMMER-962์‹ ๋‚˜์ด๋ฅผ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.

 
 

 

์ œํ•œ์‚ฌํ•ญ
  • age๋Š” ์ž์—ฐ์ˆ˜์ž…๋‹ˆ๋‹ค.
  • age ≤ 1,000
  • PROGRAMMERS-962 ํ–‰์„ฑ์€ ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž๋งŒ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

 

 

์ž…์ถœ๋ ฅ ์˜ˆ   ( age  //  result  )
23 "cd"
51 "fb"
100 "baa"

 

 


age -> stringํ™” -> charํ˜• -> ๊ฐ ์ž๋ฆฌ intํ˜•๋ณ€ํ™˜ ํ›„ ๋ฐ”๋กœ index ๊ฐ’์œผ๋กœ ์‚ฌ์šฉ


 

 

 

class Solution {
    public String solution(int age) {
        String answer = "";

        String[] alpha={"a","b","c","d","e","f","g","h","i","j"};
        String s=String.valueOf(age);
        for(char x: s.toCharArray()){
            int n=x-'0';
            answer+=alpha[n];
        }
        return answer;
    }
}