일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 프로그래머스
- LV1
- 방통대
- C++
- 선형대수
- 방송통신대학교
- leetcode
- mpnp
- omscs
- 온라인석사
- 컴퓨터과학과
- 개발자
- Plotting
- 조지아텍
- zeros
- 캐나다 영주권
- Deep learning
- 주정부이민
- 알고리즘
- 매트랩
- 마니토바
- 딥러닝
- 머신러닝
- EOI
- MATLAB
- LAA
- machine learning
- 기본
- cpp
- 코딩테스트
Archives
- Today
- Total
Krononberg
2042. Check if Numbers Are Ascending in a Sentence.cpp 본문
🔑 isdigit으로 숫자만 추출한 다음, 대소 비교를 한다.
class Solution {
public:
bool areNumbersAscending(string s) {
bool res = true;
string tmp = "";
int min = -1;
for(int i =0; i<s.size(); i++){
while(isdigit(s[i])){
tmp += s[i];
i++;
}
if(tmp!=""){
int tmpInt = stoi(tmp);
if(tmpInt > min){
min = tmpInt;
tmp = "";
}else{
return false;
}
}
}
return res;
}
};
'개발 로그 > 알고리즘' 카테고리의 다른 글
1448. Count Good Nodes in Binary Tree.cpp (0) | 2021.10.19 |
---|---|
1742. Maximum Number of Balls in a Box.cpp (0) | 2021.10.18 |
1850. Minimum Adjacent Swaps to Reach the Kth Smallest Number.cpp (0) | 2021.10.17 |
1472. Design Browser History.cpp (0) | 2021.10.15 |
861. Score After Flipping Matrix.cpp (0) | 2021.10.12 |