[프로그래머스 | Lv.0] 조건에 맞게 수열 변환하기 3

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