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 |
Tags
- 백준 17822
- 5397
- 백준 5397
- 백준 17779
- 해시구현
- AVL 시간 복잡도
- 원판 돌리기
- 구현
- 시간 복잡도
- 해시 구현
- heap
- 백준 2447
- 조세퍼스 순열
- 별 찍기 10
- 백준
- 백준 17471
- 버킷 정렬
- 게리멘더링2
- 1764
- ㅣ풀이
- qorwns
- 풀이
- 스택의 특징
- c#
- 자료구조
- C/C++ 구현
- 백준 1406
- dfs
- Stack 이란
- 백준 1158
Archives
- Today
- Total
홍시홍의 프로그래밍
[프로그래머스] 완주하지 못한자 본문
요구사항
완주하지 못한자 탐색하기
풀이
문자열 탐색이다
기본적인 해쉬문제이다
참가자에서 m[string]++;
완주자에서 m[string]--;
해준 뒤
m[string]==1 인것을 출력한다
#include <string>
#include <vector>
#include <map>
using namespace std;
const int MAX = 100100;
const int HASHSIZE = 123571;
const int PN = 23;
map<string, int> m;
string solution(vector<string> participant, vector<string> completion) {
string answer = "";
for (int i = 0; i < participant.size(); i++) {
string now = participant[i];
m[now]++;
}
for (int i = 0; i < completion.size(); i++) {
string now = completion[i];
m[now]--;
}
for (auto iter = m.begin(); iter != m.end(); iter++) {
if (iter->second == 1) {
answer = iter->first;
}
}
return answer;
}
'알고리즘 문제풀이 > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 크레인 인형뽑기 (0) | 2020.04.03 |
---|---|
[프로그래머스] 디스크 컨트롤러 (0) | 2020.03.30 |
[프로그래머스] 라면공장 (0) | 2020.03.30 |
[프로그래머스] 더 맵게 (0) | 2020.03.30 |
[프로그래머스] 위장 (0) | 2020.03.17 |
Comments