일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 선형대수
- C++
- 머신러닝
- MATLAB
- 알고리즘
- 방송통신대학교
- 마니토바
- leetcode
- 조지아텍
- 코딩테스트
- 온라인석사
- 딥러닝
- 매트랩
- 주정부이민
- LAA
- mpnp
- cpp
- 기본
- Plotting
- 컴퓨터과학과
- omscs
- LV1
- 개발자
- Deep learning
- zeros
- 프로그래머스
- 방통대
- 캐나다 영주권
- EOI
- machine learning
Archives
- Today
- Total
Krononberg
프로그래머스) 최댓값과 최솟값 c++ 본문
point : string <-> integer 변환 할 수 있는지
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
string solution(string s) {
string tmp = "";
vector<int>v;
for(int i =0; i < s.size(); i++){
if(s[i]!=' ') tmp += s[i];
else if (s[i] == ' ') {
v.push_back(stoi(tmp));
tmp = "";
}
if(i == s.size()-1)
v.push_back(stoi(tmp));
}
sort(v.begin(),v.end());
string x = to_string(v[0]) + " " + to_string(v[v.size()-1]);
return x;
}
'개발 로그 > 알고리즘' 카테고리의 다른 글
leetcode) 1769. Minimum Number of Operations to Move All Balls to Each Box / C++ (0) | 2021.09.18 |
---|---|
Leetcode) 1816. Truncate Sentence c++ (0) | 2021.09.14 |
프로그래머스) 문자열 내 마음대로 정렬하기 c++ (0) | 2021.09.04 |
프로그래머스) 월간코드챌린지2_약수의 개수와 덧셈 c++ (0) | 2021.09.03 |
프로그래머스) 비밀지도 c++ (카카오코테1차) (0) | 2021.09.03 |