๐Ÿ‘ฉ‍๐Ÿ’ปProgramming/Coding Test

[C#][programmers] ๋ฐฐ์—ด ์›์†Œ์˜ ๊ธธ์ด

taesooya 2022. 11. 10.

๋ฌธ์ž์—ด ๋ฐฐ์—ด strlist๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. strlist ๊ฐ ์›์†Œ์˜ ๊ธธ์ด๋ฅผ ๋‹ด์€ ๋ฐฐ์—ด์„ retrunํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.

 

using System;

public class Solution {
    public int[] solution(string[] strlist) {
        int[] answer = new int[strlist.Length];
        for(int i = 0; i < strlist.Length; i++)
        {
            answer[i] = strlist[i].Length;
        }
        return answer;
    }
}

string.Length๋กœ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋‹ค. Char๋กœ ๋ณ€ํ™˜ํ•˜์ง€ ์•Š์•„๋„ ๋จ / ๋ณ€ํ™˜์‹œ ๊ฐ™์€ ๊ฒฐ๊ณผ

๋Œ“๊ธ€