| 1 | class Solution { |
| 2 | public int[][] restoreMatrix(int[] rowSum, int[] colSum) { |
| 3 | int rows = rowSum.length; |
| 4 | int cols = colSum.length; |
| 5 | int r=0; |
| 6 | int c=0; |
| 7 | int resMatrix[][] = new int[rows][cols]; |
| 8 | while(r<rows && c<cols){ |
| 9 | int minVal = Math.min(rowSum[r],colSum[c]); |
| 10 | resMatrix[r][c] = minVal; |
| 11 | rowSum[r]-=minVal; |
| 12 | colSum[c]-=minVal; |
| 13 | if(rowSum[r]==0){ |
| 14 | r++; |
| 15 | }else{ |
| 16 | c++; |
| 17 | } |
| 18 | } |
| 19 | return resMatrix; |
| 20 | } |
| 21 | } |
nothing calls this directly
no outgoing calls
no test coverage detected