Skip to content

Commit 5932266

Browse files
committed
[level 2] Title: 모음 사전, Time: 2.74 ms, Memory: 87.2 MB -BaekjoonHub
1 parent 120f8dc commit 5932266

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

프로그래머스/2/84512. 모음 사전/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 95.1 MB, 시간: 2.79 ms
7+
메모리: 87.2 MB, 시간: 2.74 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2025년 09월 05일 12:37:07
19+
2025년 09월 08일 18:59:55
2020

2121
### 문제 설명
2222

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import java.util.*;
2+
23
class Solution {
3-
public char[] words = {'A', 'E', 'I', 'O', 'U'};
4-
public ArrayList<String> dictionary = new ArrayList<>();
5-
4+
public char[] words = { 'A', 'E', 'I', 'O', 'U'};
5+
ArrayList<String> list = new ArrayList<>();
66
public int solution(String word) {
77

8-
dfs(new StringBuilder(),0);
9-
int answer = dictionary.indexOf(word);
8+
dfs(new StringBuilder(), 0,word);
109

10+
int answer = list.indexOf(word) + 1;
1111
return answer;
1212
}
1313

14-
void dfs(StringBuilder current,int len) {
15-
if(len > 5) return;
16-
17-
dictionary.add(current.toString());
14+
public void dfs(StringBuilder sb , int length, String target){
15+
if(length > 0) {
16+
if(length == 5) {
17+
list.add(sb.toString());
18+
return;
19+
}
20+
list.add(sb.toString());
21+
}
1822

1923
for(char word : words) {
20-
dfs(current.append(word), len+1);
21-
current.setLength(len);
24+
dfs(sb.append(word),length + 1,target);
25+
sb.setLength(length);
2226
}
27+
2328
}
2429
}

0 commit comments

Comments
 (0)