Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 데이터애셋
- BFS
- C++
- moreeffectiveC++
- 람다
- 람다사용정렬
- stl
- 정렬
- C++최적화
- enumasByue
- 언리얼가비지컬렉터
- 정렬알고리즘
- 구조적 바인딩
- 강참조
- UE4 커스텀로그
- 애셋로드
- 자료구조
- unorder_map
- 약참조
- 스마트포인터
- map
- UELOG
- UE_LOG
- 프로그래머스
- 알고리즘
- 델리게이트
- 크리티컬섹션
- UML관련
- dataasset
- 선택정렬
Archives
- Today
- Total
기억을 위한 기록들
[프로그래머스 lv 2 ] - 영어 끝말잇기 본문
https://programmers.co.kr/learn/courses/30/lessons/12981
코딩테스트 연습 - 영어 끝말잇기
3 ["tank", "kick", "know", "wheel", "land", "dream", "mother", "robot", "tank"] [3,3] 5 ["hello", "observe", "effect", "take", "either", "recognize", "encourage", "ensure", "establish", "hang", "gather", "refer", "reference", "estimate", "executive"] [0,0]
programmers.co.kr
#include <string>
#include <vector>
#include <map>
using namespace std;
vector<int> solution(int n, vector<string> words) {
vector<int> answer;
map<string,int> m;
int size=words.size();
int i;
char lastWord;
bool find=false;
for(i=0;i<size;i++)
{
string curString=words[i];
m[curString]+=1;
if(m[curString]==2)
{
find=true;
break;
}else if( 0<i&&lastWord!=curString[0])
{
find=true;
break;
}
lastWord=curString[curString.size()-1];
}
if(find==false)
{
answer.push_back(0);
answer.push_back(0);
}else
{
answer.push_back(i%n+1);
answer.push_back(i/n+1);
}
return answer;
}
'Coding Test - cpp > String' 카테고리의 다른 글
[프로그래머스 lv 1 ] - 크기가 작은 부분문자열 (C++) (0) | 2023.11.16 |
---|---|
[프로그래머스 lv 1 ] - 4주차 직업군 추천 (0) | 2021.10.01 |
[프로그래머스 lv 1 ] - [1차] 비밀지도 (0) | 2021.09.13 |
[프로그래머스 lv 2 ] - 오픈채팅방 (0) | 2021.09.08 |
[HackerRank/C++] Repeated String (0) | 2021.07.25 |