Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5604 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 799 |

@sriramgoparaju99 | 737 |

@Manikanta punnam | 629 |

@rdakka | 606 |

@prankursharma31 | 597 |

@praveenbgp6 | 546 |

@sanskar94511 | 531 |

@purohitmn02 | 529 |

@yashkaril4 | 517 |

@abhikarshgupta | 474 |

@rohitgarg2825 | 464 |

Complete Leaderboard |

Given a NxN matrix of positive integers. There are only three possible moves from a cell **Matrix[r][c]**.

- Matrix [r+1] [c]
- Matrix [r+1] [c-1]
- Matrix [r+1] [c+1]

â€‹Starting from any column in row 0, return the largest sum of any of the paths up to row N-1.

**Example 1:**

**Input:** N = 2
Matrix = {{348, 391},
{618, 193}}
**Output:** 1009
**Explaination:** The best path is 391 -> 618.
It gives the sum = 1009.

**Example 2:**

**Input:** N = 2
Matrix = {{2, 2},
{2, 2}}
**Output:** 4
**Explaination:** No matter which path is
chosen, the output is 4.

**Your Task:**

You do not need to read input or print anything. Your task is to complete the function **maximumPath() **which takes the size N and the Matrix as input parameters and returns the highest maximum path sum.

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

**Expected Auxiliary Space:** O(N*N)

**Constraints:**

1 ≤ N ≤ 100

1 ≤ Matrix[i][j] ≤ 1000

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
Maximum path sum in matrix

...