Dsa
Dynamic Programming
Easy
Max Cost Path
Given a grid of integers representing the cost of traveling to each cell, find the maximum cost path from the top-left cell (0,0) to the bottom-right cell (n-1,m-1). You can only move right or down.
Input format:
The first line contains two integers, n and m (1 <= n, m <= 100), the dimensions of the grid.
The next n lines each contain m integers representing the cost in each cell.
Output format:
Print the maximum cost to reach the bottom-right cell.
Example:
Input:
3 3
1 2 5
3 2 1
4 3 2
Output:
12
Key concepts
dynamic_programminggrid_traversal
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now