Question bank › Dynamic Programming
Dsa Dynamic Programming Medium

Moon Landing

You are tasked with programming the landing sequence of a lunar module on a grid-shaped landing zone. The module can only land on squares marked as valid land (1), while squares marked as invalid land (0) cannot be landed on. Your task is to determine the number of distinct valid paths the lunar module can take from the top-left corner of the grid to the bottom-right corner. The module can only move right or down. Input Format: - The first line contains two integers, m (rows) and n (columns), representing the size of the grid. - The next m lines contain n integers each (0 or 1) representing the grid. Output Format: - A single integer indicating the number of distinct valid paths from the top-left to the bottom-right corner of the grid. Constraints: - 1 <= m, n <= 20 - Each cell in the grid will be either 0 or 1. Example: Input: 3 3 1 0 0 1 1 1 0 1 1 Output: 2

Key concepts

dynamic_programmingcombinatoricsgrid_paths

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