๋ฌธ์
https://school.programmers.co.kr/learn/courses/30/lessons/12981#qna
์ฝ๋
#include <string>
#include <vector>
#include <iostream>
#include <set>
using namespace std;
vector<int> solution(int n, vector<string> words) {
vector<int> answer = {0, 0};
set<string> words_set;
words_set.insert(words[0]);
for(int i = 1; i < words.size(); ++i)
{
char c = *(words[i-1].end()-1);
if(words_set.find(words[i]) == words_set.end())
{
words_set.insert(words[i]);
if(c == words[i][0])
continue;
}
answer[0] = (i % n) + 1;
answer[1] = (i / n) + 1;
break;
}
return answer;
}
'๐ฅ๏ธ Study Note > Coding Test' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค]level.2 - ํ๋ฐฐ ์์(C++) (0) | 2023.06.19 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค]level.2 - ํธํ ๋์ค(C++) (0) | 2023.06.18 |
[ํ๋ก๊ทธ๋๋จธ์ค]level.2 - ์์ ์ง๊ฟ(C++) (1) | 2023.06.12 |
[ํ๋ก๊ทธ๋๋จธ์ค]level.1 - ํธ๋ํฐ ๋ฒํธ ๊ฐ๋ฆฌ๊ธฐ(C++) (0) | 2023.06.11 |
[ํ๋ก๊ทธ๋๋จธ์ค]level.2 - ์ฐ์๋ ๋ถ๋ถ ์์ด์ ํฉ(C++) (0) | 2023.06.10 |