Skip to main content

Grid Paths

Challenge on lesson: Checkpoint — Backtracking

CHALLENGE
Difficulty: intermediate+25 XP

**Description:** Count the paths from the top-left cell (1,1) to the bottom-right cell (n,m) of a grid, moving only right or down. Some cells are blocked ('#'); paths may not pass through them. Count modulo 10^9 + 7. **Input:** Line 1: n m (1 <= n, m <= 8). Next n lines: m characters each ('.' or '#'). **Output:** One integer — the number of valid paths mod 10^9 + 7. **Example:** 2 2 / .. / #. -> 1 (only right-then-down).

Back to lesson: Checkpoint — Backtracking