프로그래머스 영어 끝말잇기 - java


프로그래머스 영어 끝말잇기 - java

import java.util.*; class Solution { public int[] solution(int n, String[] words) { int[] answer = new int[2]; // 3번 사람이 자신의 세 번째 차례에 말한 tank 라는 단어는 이전에 등장했던 단어이므로 탈락하게 됩니다. // 가장 먼저 탈락하는 사람의 번호와 그 사람이 자신의 몇 번째 차례에 탈락하는지 int loopCount = 1; Set<String> wordsSpoken = new HashSet<>(); boolean gameIsGoOn = true; char lastChar = words[0].charAt(0); while (gameIsGoOn) { // 0 n 2n 3n... for (int i = n*(loopCount-1) ; i < n*(loopCount) && i < words.length ; i++){ if (lastChar != words[i].charAt(0) || wo...



원문링크 : 프로그래머스 영어 끝말잇기 - java