안녕하세요!
오늘은 [PCCE 기출문제] 10번 / 데이터 분석 (C++) 문제를 풀어봐요!
LV.1 난이도의 단순한 문제에용!
map 자료구조와 algorithm 라이브러리의 sort함수를 잘 활용하면 된답니다!
https://school.programmers.co.kr/learn/courses/30/lessons/250121
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
map<string, int> extMap;
int curExt = 0;
bool Comp(vector<int>& a, vector<int>& b)
{
return a[curExt] < b[curExt];
}
vector<vector<int>> solution(vector<vector<int>> data, string ext, int val_ext, string sort_by) {
vector<vector<int>> answer;
extMap["code"] = 0;
extMap["date"] = 1;
extMap["maximum"] = 2;
extMap["remain"] = 3;
curExt = extMap[ext];
for(int i = 0; i < data.size(); ++i)
{
if(data[i][curExt] < val_ext)
{
answer.push_back(data[i]);
}
}
curExt = extMap[sort_by];
sort(answer.begin(), answer.end(), Comp);
return answer;
}'코딩테스트 > 프로그래머스' 카테고리의 다른 글
| 프로그래머스 광물 캐기 (C++) (0) | 2024.10.21 |
|---|---|
| 프로그래머스 택배 배달과 수거하기 (C++) (0) | 2024.10.21 |
| 프로그래머스 두 원 사이의 정수 쌍 (C++) (0) | 2024.10.07 |
| 프로그래머스 달리기 경주 (C++) (1) | 2024.10.05 |
| 프로그래머스 [PCCE 기출문제] 9번 / 이웃한 칸 (C++) (1) | 2024.10.03 |