Question link: https://www.codechef.com/COOK92B/problems/CO92MATR
The problem asked that, we have replace each -1 with +ve integers, such that all rows and columns are in non-decreasing order. So, i am taking a 2D array and taking the input. But, to go to each '-1' and comparing it with its neighbouring elements(which can be atmax 4), will require use of LOTS OF NESTED LOOPS. And adding to that we have to consider all the possible cases where -1 can be,like at the top or top-left or middle of the matrix.
Is there is any easier and compact approach to this problem ?