Question bank › Dynamic Programming
Dsa Dynamic Programming Warm-up

Path of Stars

You are trying to navigate through a star field represented as a grid. Each cell in the grid contains a non-negative integer representing the energy needed to enter that cell. You wish to find the minimum energy required to travel from the top left corner to the bottom right corner of the grid. You can only move right and down. Write a program to compute this minimal value. Input format: - The first line contains integers N (1 ≤ N ≤ 50), M (1 ≤ M ≤ 50) which represent the number of rows and columns in the grid. - The next N lines contain M space-separated integers, representing the energy values of each cell. Output format: - A single integer indicating the minimum energy required to reach the target cell. Example: Input: 3 3 1 3 1 1 5 1 4 2 1 Output: 7

Key concepts

dynamic_programminggridpathfinding

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.