[문제링크 - 프로그래머스 - 행렬의 덧셈] https://school.programmers.co.kr/learn/courses/30/lessons/12950
class Solution {
public int[][] solution(int[][] arr1, int[][] arr2) {
int[][] answer = new int[arr1.length][arr1[0].length];
for(int i=0; i<arr1.length; i++){
for(int j=0; j<arr1[0].length; j++){
answer[i][j] = arr1[i][j] + arr2[i][j];
}
}
return answer;
}
}
answer = arr1 + arr2
형식이 아닌 answer += arr2
로 구현가능 하다는 것을 알게되었다.class Solution {
public int[][] solution(int[][] arr1, int[][] arr2) {
int[][] answer = {};
answer = arr1;
for(int i=0; i<arr1.length; i++){
for(int j=0; j<arr1[0].length; j++){
answer[i][j] += arr2[i][j];
}
}
return answer;
}
}