[프로그래머스/C++]Lv.0 - 배열 원소의 길이

YH J·2023년 4월 18일
0

프로그래머스

목록 보기
40/168

문제 링크

https://school.programmers.co.kr/learn/courses/30/lessons/120854

내 풀이

각 원소의 길이 계산해서 저장

내 코드

#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<string> strlist) {
    vector<int> answer;
    
    for(const auto& s : strlist)
    {
        answer.push_back(s.length());
    }
    return answer;
}

다른 사람의 풀이

#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<string> strlist) {
    vector<int> answer;
    for(auto str : strlist)
        answer.push_back(str.length());

    return answer;
}

다른 사람의 풀이 해석

같은 방법이다.

profile
게임 개발자 지망생

0개의 댓글