| Conditions | 5 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public static function uniquePathsWithObstacles(array $grids): int |
||
| 10 | { |
||
| 11 | [$m, $n] = [count($grids), count($grids[0])]; |
||
| 12 | if ($m <= 0 || $n <= 0) { |
||
| 13 | return 0; |
||
| 14 | } |
||
| 15 | $dp = array_fill(0, $m, array_fill(0, $n, 0)); |
||
| 16 | $dp[0][1] = 1; |
||
| 17 | for ($i = 1; $i < $m; $i++) { |
||
| 18 | for ($j = 1; $j < $n; $j++) { |
||
| 19 | $dp[$i][$j] = $dp[$i - 1][$j] + $dp[$i][$j - 1]; |
||
| 20 | } |
||
| 21 | } |
||
| 22 | |||
| 23 | return $dp[$m - 1][$n - 1]; |
||
| 24 | } |
||
| 47 |