JAVA_LeetCode 1252_Cells with Odd Values in a Matrix


JAVA_LeetCode 1252_Cells with Odd Values in a Matrix

JAVA_LeetCode 1252_Cells with Odd Values in a Matrix 풀이 class Solution { public int oddCells(int m, int n, int[][] indices) { int[][] arr=new int[m][n]; int cnt=0, row = 0, col = 0; // indices에서 값을 추출한다. for(int i=0;i<indices.length;i++){ row = indices[i][0]; col = indices[i][1]; for(int j = 0;j < n; j++) arr[row][j]++; for(int j = 0;j < m; j++) arr[j][col]++; } // 홀수 체크 for(int j = 0;j < m; j++){ for(int k = 0;k < n; k++){ if(arr[j][k] % 2 != 0) cnt++; } } return cnt; } } * 출처 https://leetcode....


#JAVA #JAVA_CellswithOddValuesinaMatrix #JAVA_LeetCode1252 #JAVA_LeetCode1252_CellswithOddValuesinaMatrix #LeetCode1252_CellswithOddValuesinaMatrix

원문링크 : JAVA_LeetCode 1252_Cells with Odd Values in a Matrix