[프로그래머스 | C# | Lv.0] 이차원 배열 대각선 순회하기

728x90

https://school.programmers.co.kr/learn/courses/30/lessons/181829

 

📝 나의 풀이

using System;

public class Solution {
    public int solution(int[,] board, int k) {
        int answer = 0;
        
        for(int i=0; i<board.GetLength(0); i++){
            for(int j=0; j<board.GetLength(1); j++){
                if(i+j<=k){
                    answer += board[i,j];
                }
            }
        }
        return answer;
    }
}
728x90