본문 바로가기
코딩테스트/LV. 0

LV. 0 :: 배열 원소의 길이

by KUROMI98 2023. 1. 20.

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

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

function solution(strlist) {
    var answer = [];
    for (i=0; i<strlist.length; i++){
        answer[i] = strlist[i].length;
    }
    return answer;
}

+)230509

const solution = (strlist) => {
    return strlist.map(x => x.length);
}

230525 파이썬

def solution(strlist):
    return [len(x) for x in strlist]

230915 C++

#include <string>
#include <vector>

using namespace std;

vector<int> solution(vector<string> strlist) {
    vector<int> answer(strlist.size());
    for(int i=0;i<strlist.size();i++){
        answer[i] = strlist[i].size();
    }
    return answer;
}

'코딩테스트 > LV. 0' 카테고리의 다른 글

LV. 0 :: 피자 나눠 먹기 3  (0) 2023.01.20
LV. 0 :: 배열 뒤집기  (0) 2023.01.20
LV. 0 :: 아이스 아메리카노  (0) 2023.01.20
LV. 0 :: 짝수의 합  (0) 2023.01.20
LV. 0 :: 두 수의 나눗셈  (0) 2023.01.20

댓글