Problem Solving/Programmers

[Level 2] 모음 사전

kmkunk 2022. 4. 6. 12:56
class Solution {
    public int solution(String word) {
        int answer = word.length();
        String s = "AEIOU";
        int[] n = new int[]{781, 156, 31, 6, 1};
        
        for(int i=0; i<word.length(); i++) {
            answer += n[i]*s.indexOf(String.valueOf(word.charAt(i)));
        }
        
        return answer;
    }
}