Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5578 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3412 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 714 |

@Manikanta punnam | 587 |

@sriramgoparaju99 | 532 |

@praveenbgp6 | 525 |

@yashkaril4 | 517 |

@prankursharma31 | 489 |

@rdakka | 467 |

@sonamnigam1999 | 441 |

@sonamkumari63928 | 427 |

@purohitmn02 | 427 |

@shubhamstudent5 | 419 |

Complete Leaderboard |

Given a grid of size **M*N** with each cell consisting of an integer which represents points. We can move across a cell only if we have positive points. Whenever we pass through a cell, points in that cell are added to our overall points, the task is to find minimum initial points to reach cell (m-1, n-1) from (0, 0) by following these certain set of rules :

1. From a cell (i, j) we can move to (i + 1, j) or (i, j + 1).

2. We cannot move from (i, j) if your overall points at (i, j) are <= 0.

3. We have to reach at (n-1, m-1) with minimum positive points i.e., > 0.

**Example 1:**

Input: M = 3, N = 3 arr[][] =`{{-2,-3,3},`

`{-5,-10,1},`

`{10,30,-5}`

`};`

Output:7Explanation: 7 is the minimum value to reach the destination with positive throughout the path. Below is the path. (0,0) -> (0,1) -> (0,2) -> (1, 2) -> (2, 2) We start from (0, 0) with 7, we reach (0, 1) with 5, (0, 2) with 2, (1, 2) with 5, (2, 2) with and finally we have 1 point (we needed greater than 0 points at the end).

**Input: **M = 3, N = 2
arr[][] = `{{2,3}, `

` {5,10}, `

` {10,30}`

`}; `

**Output: **1
**Explanation**: Take any path, all of them
are positive. So, required one point
at the start

**Your Task: **

You don't need to read input or print anything. Complete the function ** minPoints() **which takes

1 ≤ N ≤ 10

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?

Yes
Minimum Points To Reach Destination

...