728x90
https://school.programmers.co.kr/learn/courses/30/lessons/181901
📝 나의 풀이
using System;
public class Solution {
public int[] solution(int n, int k) {
int[] answer = new int[n/k];
int index=0;
for(int i=1; i<=n; i++){
if(i%k==0) {
answer[index] = i;
index++;
}
}
return answer;
}
}
728x90
'코딩테스트 > [C#] 프로그래머스' 카테고리의 다른 글
[프로그래머스 | C# | Lv.0] 마지막 두 원소 (0) | 2023.08.31 |
---|---|
[프로그래머스 | C# | Lv.0] 접미사인지 확인하기 (0) | 2023.08.31 |
[프로그래머스 | C# | Lv.0] 접두사인지 확인하기 (0) | 2023.08.30 |
[프로그래머스 | C# | Lv.0] 글자 이어 붙여 문자열 만들기 (0) | 2023.08.29 |
[프로그래머스 | C# | Lv.0] 특정한 문자를 대문자로 바꾸기 (0) | 2023.08.29 |