์ฒด๊ฐ Level : โ
โ โ Review: ํด์ฌ๋งต ์ฌ์ฉ |
import java.util.HashMap;
class Solution {
public String solution(String letter) {
String answer = "";
HashMap<String, String> m = new HashMap<>();
//๋ชจ์ค๋ถํธ ํด์๋งต์ ์ถ๊ฐ
m.put(".-","a");m.put("-...","b");m.put("-.-.","c");m.put("-..","d");
m.put(".","e");m.put("..-.","f");m.put("--.","g");m.put("....","h");
m.put("..","i");m.put(".---","j");m.put("-.-","k");m.put(".-..","l");
m.put("--","m");m.put("-.","n");m.put("---","o");m.put(".--.","p");
m.put("--.-","q");m.put(".-.","r");m.put("...","s");m.put("-","t");
m.put("..-","u");m.put("...-","v");m.put(".--","w");m.put("-..-","x");
m.put("-.--","y");m.put("--..","z");
String[] arr = letter.split(" ");
// ํค(๋ชจ์ค๋ถํธ)์ ๋ง๋ ๊ฐ(์๋ฌธ์) ๊ฐ์ ธ์ค๊ธฐ
for (String s : arr){
answer += m.get(s);
}
return answer;
}
}