#include <string>
#include <vector>
#include <map>
using namespace std;
vector<int> solution(int n, vector<string> words) {
vector<int> answer;
map<string, int> temp;
int num = 1, turn = 1;
char last = words[0][0];
for (int i = 0; i < words.size(); i++)
{
string word = words[i];
if (last != word[0])
{
answer.push_back(num);
answer.push_back(turn);
break;
}
if (temp[word] == 0)
temp[word] = num;
else
{
answer.push_back(num);
answer.push_back(turn);
break;
}
num++;
last = word[word.size() - 1];
if (num == n + 1)
{
num = 1;
turn++;
}
}
if (answer.empty())
{
answer.push_back(0);
answer.push_back(0);
}
return answer;
}
크게 어려울것 없는 구현 문제였다.
'Coding_Test 연습 > Programmers' 카테고리의 다른 글
| [프로그래머스] (C++) LV2 구명보트 (0) | 2022.06.01 |
|---|---|
| [프로그래머스] (C++) LV2 주식가격 (0) | 2022.06.01 |
| [프로그래머스] (C++) LV2 삼각 달팽이 (0) | 2022.06.01 |
| [프로그래머스] (C++) LV2 2개 이하로 다른 비트 (0) | 2022.06.01 |
| [프로그래머스] (C++) LV2 피로도 (0) | 2022.06.01 |