240123 모음사전

Jongleee·2024년 1월 24일
0

TIL

목록 보기
476/576
public int solution(String word) {
	int answer = 0;
	int[] lengths = { 781, 156, 31, 6, 1 };
	String vowels = "AEIOU";

	for (int i = 0; i < word.length(); i++) {
		char ch = word.charAt(i);
		int index = vowels.indexOf(ch) + 1;

		answer += (index - 1) * lengths[i] + 1;
	}

	return answer;
}

출처:https://school.programmers.co.kr/learn/courses/30/lessons/84512

0개의 댓글