230822 행렬의 덧셈

Jongleee·2023년 8월 22일
0

TIL

목록 보기
344/576
public int[][] solution(int[][] arr1, int[][] arr2) {
	int rows = arr1.length;
	int cols = arr1[0].length;
	int[][] result = new int[rows][cols];

	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < cols; j++) {
			result[i][j] = arr1[i][j] + arr2[i][j];
		}
	}

	return result;
}

출처:https://school.programmers.co.kr/learn/courses/30/lessons/12950

0개의 댓글