Algorithms Playbook
← All problems
Medium2D dynamic programming →Similar to: Unique Paths

Robot on a grid

Problem

A robot starts at the top-left of an m × n grid and wants to reach the bottom-right, moving only right or down. Some cells are blocked (1). Return the number of different paths.

Examples

Input: [[0,0,0],[0,1,0],[0,0,0]]

Output: 2

Input: [[0,1],[0,0]]

Output: 1

Hints

    Try it first. Every hint reveals a bit more.

    Solution