
- 난이도: Lv2
프로그래머스 링크: https://school.programmers.co.kr/learn/courses/30/lessons/12981
풀이 링크(GitHub): hayannn/CodingTest_Java/프로그래머스/2/영어 끝말잇기




풀이 시간 : 25분
import java.util.*;
class Solution {
    public int[] solution(int n, String[] words) {
        Set<String> usedWords = new HashSet<>();
        for (int i = 0; i < words.length; i++) {
            if (!usedWords.add(words[i]) || (i > 0 && words[i - 1].charAt(words[i - 1].length() - 1) != words[i].charAt(0))) {
                return new int[]{(i % n) + 1, (i / n) + 1};
            }
        }
        return new int[]{0, 0};
    }
}

