Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 실습
- 언리얼 커스텀 플러그인
- 언리얼 플러그인
- hackerank
- objtofbx
- UnrealMP
- 오손데이터읽기
- 민겸수
- SQL
- command not found
- UActor
- 1759번
- 1253번
- 트랜잭션 관리
- C++
- Security
- 의미와 무의미의 경계에서
- 비재귀셰그먼트
- OS
- Unreal
- 1967번
- oracle
- 5639
- FBX
- Linux
- 데이터베이스 배움터
- 백준 1253번
- 셰그먼트트리
- 백준
- 2단계로킹
Archives
- Today
- Total
fatalite
C++ / 영어 끝말잇기 본문
Problem
문제 난이도 : Programmers 2단계 69%
분류 : Implementation 같음
Solution
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> solution(int n, vector<string> words) {
vector<int> answer;
answer.push_back(0);
answer.push_back(0);
vector<string> UsedWords;
UsedWords.push_back(words[0]);
for(int i = 1; i < words.size(); i++){
if(find(UsedWords.begin(),UsedWords.end(),words[i]) == UsedWords.end()){
if(UsedWords.back().back() != words[i].front()){
cout << i << endl;
answer[0] = i % n + 1;
answer[1] = i / n + 1;
break;
}else{
UsedWords.push_back(words[i]);
}
}else{
answer[0] = i % n + 1;
answer[1] = i / n + 1;
cout << i << endl;
break;
}
}
return answer;
}
'코딩 인터뷰 > 프로그래머스' 카테고리의 다른 글
C++ / 구명보트 (0) | 2023.05.08 |
---|---|
C++ / 카펫 (0) | 2023.05.07 |
C++ / 숫자의 표현 (0) | 2023.04.24 |
C++ / 이진 변환 반복하기 (0) | 2023.04.24 |
C++ / 올바른 괄호 (0) | 2023.04.22 |