- intuition behind the problem is simple to follow
- possibly being greedy, and taking the highest possible value that is <= to the colSum and rowSum for that particular position
π€What Did I Struggle With?
after the first iteration, how do we keep track of the sum remaining for the next position
π‘ Explanation of Solution
- initialize a matrix of size n*m (size of rowSum and colSum vectors respectively) with their values to 0
- nested loop iterating through rows and cols
- calculate the maxValue you can place in the current position ~ min(rowSum[i], colSum[i])
- place that value in the position in the matrix
- decrement the row and col sums with by that value, leaving the remaining for the next positions
β Complexity Analysis
Time Complexity: O(n*m) where n is the number of rows and m is the number of columns in the matrix
Space Complexity: O(n*m) for creation and population of the matrix