코딩테스트/[C#] 프로그래머스
[프로그래머스 | Lv.0] 조건에 맞게 수열 변환하기 3
냠냠쿠
2023. 8. 13. 19:39
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