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