data-structures · intermediate · ~15 min
Count grid paths around obstacles.
Implement:
int count_maze_paths(const int *grid, int rows, int cols);
Count paths from top-left to bottom-right moving only right or down; cells with value 1 are blocked.
Row-major 0/1 grid, dimensions.
Number of paths.
A blocked cell contributes 0 paths.
#include <stddef.h>
/* Count paths from top-left to bottom-right of a rows x cols grid moving only right/down; cells with value 1 are blocked. */
int count_maze_paths(const int *grid,int rows,int cols){ (void)grid;(void)rows;(void)cols; return 0; }
Recursing off the grid edges; forgetting to stop on a blocked cell.
A blocked start or end gives 0.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.