웅재의 코딩세상
[프로그래머스] 문자 개수 세기 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
vector<int> solution(string my_string) {
vector<int> answer(52,0);
for(int i=0; i<my_string.size(); i++){
if(my_string[i] < 'a') answer[my_string[i]- 'A']++;
else answer[my_string[i] - 'a'+26]++;
}
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] 가까운 1 찾기 (0) | 2024.01.31 |
---|---|
[프로그래머스] 글자 지우기 (0) | 2024.01.31 |
[프로그래머스] qr code (0) | 2024.01.31 |
[프로그래머스] 세로 읽기 (0) | 2024.01.31 |
[프로그래머스] 문자열 뒤집기 (0) | 2024.01.31 |