Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6564 |

@blackshadows | 6400 |

@mb1973 | 5785 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4639 |

@sanjay05 | 3762 |

@mantu_singh | 3712 |

@gfgaccount | 3627 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@yaswanthero123 | 625 |

@vikash619 | 611 |

@venkat11803610 | 501 |

@roshan13ar | 396 |

@DevangSingh | 379 |

@ravi11815721 | 312 |

@hrishipangavhane | 286 |

@aryanjain85297 | 280 |

@kommaraju11806903 | 277 |

@infosumitraut | 272 |

@ankitsharma5422 | 256 |

Complete Leaderboard |

Given **n** arrays of size **m **each. Find maximum sum obtained by selecting a number from each array such that the element selected from the **i-th** array is more than the element selected from **(i-1)-th** array. If maximum sum cannot be obtained then return **0**.

**Example 1:**

**â€‹Input :** arr[ ] = {{1,7,4,3}, {4,2,5,1}, {9,5,1,8}}
**Output :** 18
**Explanation:**
We can select 4 from the first array,
5 from second array and 9 from the third array.

**â€‹Example 2:**

**Input :** arr[ ] = {{9,8,7}, {6,5,4}, {3,2,1}} **
Output :** 0

**Your Task:**

This is a function problem. The input is already taken care of by the driver code. You only need to complete the function **maximumSum()** that takes number of row **N**, a number of Column** M**, 2-d array **(arr)**, and return the maximum sum if cannot be obtained then return **0**. The driver code takes care of the printing.

**Expected Time Complexity:** O(N*M).

**Expected Auxiliary Space:** O(1).

**Constraints:**

1 ≤ N, M ≤ 500

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Maximum sum of increasing order elements from n arrays

...