https://school.programmers.co.kr/learn/courses/30/lessons/12981
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <bits/stdc++.h>
std::vector<int> solution(int n, std::vector<std::string> words) {
std::vector<int> answer;
std::unordered_set<std::string> history;
std::string preWord = words[0];
history.insert(words[0]);
std::string currWord;
for (int i = 1; i < words.size(); ++i){
currWord = words[i];
if (history.find(currWord) != history.end() || preWord.back() != currWord[0]){
return {i % n + 1, i / n + 1};
}
history.insert(currWord);
preWord = currWord;
}
return {0, 0};
}
'프로그래머스 문제풀이 > LEVEL 2' 카테고리의 다른 글
[C++] 프로그래머스 문제풀이 LEVEL 2 예상 대진표 (0) | 2023.07.03 |
---|---|
[C++] 프로그래머스 문제풀이 LEVEL 2 카펫 (0) | 2023.07.03 |
[C++] 프로그래머스 문제풀이 LEVEL 2 짝지어 제거하기 (0) | 2023.07.03 |
[C++] 프로그래머스 문제풀이 LEVEL 2 피보나치 수 (0) | 2023.07.03 |
[C++] 프로그래머스 문제풀이 LEVEL 2 다음 큰 숫자 (0) | 2023.07.03 |