웅재의 코딩세상
[프로그래머스] 이차원 배열 대각선 순회하기 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
int solution(vector<vector<int>> board, int k) {
int answer = 0;
for(int i=0; i<board.size(); i++){
for(int j=0; j<board[i].size(); j++){
if(i+j <= k) answer += board[i][j];
}
}
return answer;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] 특정 문자열로 끝나는 가장 긴 부분 문자열 찾기 (0) | 2024.02.01 |
---|---|
[프로그래머스] 날짜 비교하기 (0) | 2024.02.01 |
[프로그래머스] 두 수의 합 (0) | 2024.02.01 |
[프로그래머스] 문자열 묶기 (0) | 2024.02.01 |
[프로그래머스] 세 개의 구분자 (0) | 2024.02.01 |