문자열 배열 strlist가 매개변수로 주어집니다. strlist 각 원소의 길이를 담은 배열을 retrun하도록 solution 함수를 완성해주세요.
내 풀이
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<string> strlist) {
vector<int> answer;
for(int i = 0; i<strlist.size(); i++){
answer.push_back(strlist[i].size());
}
return answer;
}
출처: https://school.programmers.co.kr/learn/courses/30/lessons/120854
'밥벌이 > 코딩테스트' 카테고리의 다른 글
프로그래머스 점의 위치 구하기 (7/100) (0) | 2022.12.12 |
---|---|
프로그래머스 문자열 뒤집기(6/100) (0) | 2022.12.12 |
프로그래머스 피자 나눠 먹기(나누기) (4/100) (0) | 2022.12.12 |
프로그래머스 범위기반 for문 (3/100) (0) | 2022.12.05 |
프로그래머스 배열뒤집기(2/100) (0) | 2022.12.05 |