Maximize sum of K elements selected from a Matrix such that each selected element must be preceded by selected row elements
Given a 2D array arr[][] of size N * M, and an integer K, the task is to select K elements with maximum possible sum such that if an element arr[i][j] is selected, then all the elements from the ith row present before the jth column needs to be selected. Examples: Input: arr[][] = {{10, 10, 100, 30}, {80, 50, 10, 50}}, K = 5Output: 250Explanation:S