diff --git "a/\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.cpp" "b/\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.cpp" new file mode 100644 index 0000000..6af8491 --- /dev/null +++ "b/\354\230\201\354\226\264\353\201\235\353\247\220\354\236\207\352\270\260.cpp" @@ -0,0 +1,28 @@ +#include +#include +#include + +using namespace std; + +vector solution(int n, vector words) { + vector answer = {0, 0}; + map temp; + + char end = words[0][0]; + for(int i = 0; i < words.size(); ++i) + { + string str = words[i]; + if(temp.find(str) != temp.end() || end != str[0]) + { + answer[0] = (i+1) % n == 0 ? n : (i+1) % n; + answer[1] = (i+1) % n == 0 ? (i+1) / n : ((i+1) / n) + 1; + return answer; + } + + temp.insert({str, 1}); + + end = str[str.size() - 1]; + } + + return answer; +}