solulubeta
Sign in
Recursion & Memo / DP patterns for coding tests
04.03 · Problem

Unique Paths With Obstacles

Medium Grid DP: count paths LC 63 Pro

A robot moves only right or down, from the top-left cell to the bottom-right cell. Cells with 1 are walls. Count the paths. If the start or the end is a wall, the answer is 0.

Examples

Example 1

Input:  grid = [[0, 0, 0],
                [0, 1, 0],
                [0, 0, 0]]
Output: 2

Around the obstacle either over the top (right, right, down, down) or along the left side (down, down, right, right).

solulu Pro

Continue this problem with Pro

Inside: step-by-step hints · 10 hidden tests · reference solutions · code editor.

Lifetime ₹1,999 ₹999 · Launch offer
Mark this problem as solved when you are finished.

Item 29 of 44 · updated 2026-10-13