Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |
Tags
- BFS
- 프로그래머스
- priorityqueue
- 운동기록
- 건강
- BOJ
- 문제풀이
- 문자열
- oracle
- db
- 백준
- 코딩테스트
- SWEA
- dfs
- 시뮬레이션
- COS PRO
- 자바
- greedy
- 알고리즘
- math
- 코테
- 이분탐색
- 러닝일지
- SQL
- 투포인터
- MySQL
- 문제해결
- binary search
- DP
- Java
Archives
- Today
- Total
슈콩
COS PRO 1급 JAVA 사전에서 단어찾기 본문


[소스 코드]
import java.util.*;
public class Main {
String[] vowels = {"A", "E", "I", "O", "U"};
ArrayList<String> words;
public void create_words(int lev, String str) {
words.add(str);
for (int i = 0; i < 5; i++) {
if (lev < 5) {
create_words(lev+1, str.concat(vowels[i]));
}
}
}
public int solution(String word) {
int answer = 0;
words = new ArrayList<String>();
create_words(0, "");
for (int i = 0; i < words.size(); i++) {
if (word.equals(words.get(i))) {
answer = i;
break;
}
}
return answer;
}
}