웅재의 코딩세상
[프로그래머스] x 사이의 개수 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
vector<int> solution(string myString) {
vector<int> answer;
string s="";
for(int i=0; i<myString.size(); i++){
if(myString[i] == 'x') {
answer.push_back(s.size());
s = "";
}
else s += myString[i];
}
answer.push_back(s.size());
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] 배열 만들기 3 (0) | 2024.01.31 |
---|---|
[프로그래머스] 수열과 구간 쿼리 1 (0) | 2024.01.31 |
[프로그래머스] l로 만들기 (0) | 2024.01.31 |
[프로그래머스] ad 제거하기 (0) | 2024.01.31 |
[프로그래머스] 꼬리 문자열 (0) | 2024.01.31 |