Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Iterate from the first to the last row and if there exist some unmarked cells, take a maximum from them and mark that cell as visited.
Add a maximum of newly marked cells to answer and repeat that operation until the whole matrix becomes marked.