Question bank › Dynamic Programming
Dsa Dynamic Programming Warm-up

Minimum Steps to Target

You have a grid of size m x n, where each cell has a non-negative integer cost. You start from the top-left corner (0,0) and need to reach the bottom-right corner (m-1,n-1) while minimizing the total cost. Write a function to compute the minimum cost path to reach the target cell. Input Format: - The first line contains two integers, m and n (1 <= m, n <= 50). - The next m lines each contain n space-separated integers representing the costs in the grid. Output Format: - A single integer representing the minimum cost to reach the target cell. Example: Input: 2 2 1 3 2 1 Output: 3

Key concepts

dynamic_programminggridminimum_cost

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.