728x90
https://school.programmers.co.kr/learn/courses/30/lessons/181835
📝 나의 풀이
using System;
public class Solution {
public int[] solution(int[] arr, int k) {
int[] answer = new int[arr.Length];
for(int i=0; i<arr.Length; i++){
if(k%2!=0){
answer[i] = arr[i] * k;
} else {
answer[i] = arr[i] + k;
}
}
return answer;
}
}
728x90
'코딩테스트 > [C#] 프로그래머스' 카테고리의 다른 글
[프로그래머스 | Lv.0] 첫 번째로 나오는 음수 (0) | 2023.08.13 |
---|---|
[프로그래머스 | Lv.0] 소문자로 바꾸기 (0) | 2023.08.13 |
[프로그래머스 | Lv.0] n 번째 원소부터 (0) | 2023.08.13 |
[프로그래머스 | Lv.0] 문자열의 앞의 n글자 (1) | 2023.08.13 |
[프로그래머스 | Lv.0] 원소들의 곱과 합 (0) | 2023.08.13 |