Unique Paths II

Medium Solved

Description

You are given an m × n grid. The robot starts at the top-left corner and wants to reach the bottom-right corner.

Some cells contain obstacles (1) and others are empty (0). The robot can only move right or down.

Return the number of unique paths from start to finish.

Input format:

  • Line 1: JSON 2D array (0 = empty, 1 = obstacle)

Examples

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

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

Output:
1

Note:

Print a single integer representing the total number of unique paths.

No submissions yet.

Discuss dynamic programming with obstacles, edge cases, and space optimization.

Test Cases