카카오/2019 카카오 개발자 겨울 인턴십
[C++] 2019 카카오 개발자 겨울 인턴십 - 튜플
코딩준우
2023. 7. 9. 16:56
https://school.programmers.co.kr/learn/courses/30/lessons/64065
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <bits/stdc++.h>
std::vector<int> solution(std::string s) {
std::vector<int> answer;
int cnt[100001] = { 0, };
std::string num;
for(char ch : s){
if (ch >= '0' && ch <= '9'){
num += ch;
}
else{
if(num.length())
++cnt[std::stoi(num)];
num.clear();
}
}
std::vector<std::pair<int, int>> pairs;
for(int i = 0; i < 100001; ++i){
if(cnt[i]) pairs.push_back({cnt[i], i});
}
std::sort(pairs.begin(), pairs.end(), std::greater<>());
for(auto pair: pairs) answer.push_back(pair.second);
return answer;
}