๋ฌธ์
์ฝ๋
#include <iostream>
#include <unordered_set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
vector<int> solution(string s) {
vector<int> answer;
vector<pair<int,vector<string>>>v;
map<string,int>m;
for(int i=1; i<s.length()-1; i++){
string temp_s;
vector<string>temp_v;
if(s[i]=='{'){
while(s[i]!='}'&&i!=s.length()-1){
if(s[i]>='0'&&s[i]<='9'&&s[i]!=' ')temp_s+=s[i];
else{
temp_v.push_back(temp_s);
temp_s.clear();
}
i++;
}
if(temp_s.length()!=0) temp_v.push_back(temp_s);
v.push_back({temp_v.size(),temp_v});
}
}
sort(v.begin(),v.end());
for(int i=0; i<v.size(); i++){
for(int k=1; k<v[i].second.size(); k++){
if(m[v[i].second[k]]==0){
m[v[i].second[k]]++;
answer.push_back(stoi(v[i].second[k]));
}
}
}
return answer;
}
'Algorithm ๐ง๐ปโ๐ป > ํ๋ก๊ทธ๋๋จธ์ค(Programmers)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์๋ ์ซ์ ๋ํ๊ธฐ( Level 1) (0) | 2021.11.07 |
---|---|
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํธ๋ํฐ ๋ฒํธ ๊ฐ๋ฆฌ๊ธฐ( Level 1) (0) | 2021.10.23 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํฐ์ผ๋ชฌ( Level 2) (0) | 2021.10.23 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํ๊ฒ ๋๋ฒ( Level 2) (0) | 2021.10.23 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์นด์นด์ค ํ๋ ์ฆ ์ปฌ๋ฌ๋ง๋ถ( Level 2, 2017 ์นด์นด์ค ์ฝ๋ ์์ ) (0) | 2021.10.23 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ต๋๊ฐ๊ณผ ์ต์๊ฐ( Level 2) (0) | 2021.10.22 |
๋๊ธ