We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 88c3071 + 2260a3f commit 2c69d30Copy full SHA for 2c69d30
lkhyun/202510/17 PGM Lv2 영어 끝말잇기.md
@@ -0,0 +1,28 @@
1
+```java
2
+import java.util.*;
3
+class Solution {
4
+ public int[] solution(int n, String[] words) {
5
+
6
+ Map<String,Boolean> history = new HashMap<>();
7
8
+ int fail = 0;
9
+ String prev = words[0];
10
+ history.put(prev,true);
11
+ for(int i=1;i<words.length;i++){
12
+ if(prev.charAt(prev.length()-1) == words[i].charAt(0)
13
+ && history.get(words[i]) == null
14
+ && words.length>1){
15
+ prev = words[i];
16
+ history.put(words[i],true);
17
+ }else{
18
+ fail = i;
19
+ break;
20
+ }
21
22
+ if(fail == 0){
23
+ return new int[]{0,0};
24
25
+ return new int[]{(fail%n)+1,(fail/n)+1};
26
27
+}
28
+```
0 commit comments