프로그래머스/C++4 [프로그래머스/C++] 해시 - 베스트앨범 programmers.co.kr/learn/courses/30/lessons/42579 #include #include #include #include using namespace std; vector solution(vector genres, vector plays) { vector answer; unordered_map genreMap; const int &SIZE=genres.size(); for (int i=0; isecond, it->first)); } sort(vec.begin(), vec.end()); const int &GenreKind=vec.size(); vector vec2; for (int i = 0; i < GenreKind; i++) { vec2.push_back(vec[i].s.. 2021. 1. 2. [프로그래머스/C++] 해시 - 전화번호 목록 programmers.co.kr/learn/courses/30/lessons/42577 #include #include #include using namespace std; bool solution(vector phone_book) { bool answer = true; sort(phone_book.begin(),phone_book.end()); for (int i=0; i 2021. 1. 1. [프로그래머스/C++] 해시 - 위장 programmers.co.kr/learn/courses/30/lessons/42578 #include #include #include using namespace std; int solution(vector clothes) { int answer = 1; unordered_map clothMap; for (int i=0; isecond) + 1 ; } return answer-1; } 바로 전 완주하지 못한 선수 문제를 활용하여 서로 다른 의상의 이름을 key로 개수를 value로 가지는 clothMap이라는 unordered_map 변수를 형성한다. 의상의 종류가 다를 경우 이름이 같더라도 하나만 입을 수 있거나 아예 입을 수 없다. 즉, 한 의상의 종류당 '종류는 같지만 이름은 다른 개수+1'가지의.. 2020. 12. 31. [프로그래머스/C++] 해시 - 완주하지 못한 선수 programmers.co.kr/learn/courses/30/lessons/42576 #include #include #include using namespace std; string solution(vector participant, vector completion) { string answer = ""; sort(participant.begin(), participant.end()); sort(completion.begin(), completion.end()); answer = participant[participant.size()-1]; for (int i=0; i 2020. 12. 31. 이전 1 다음