Guest User

Untitled

a guest
Apr 26th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. package main
  2.  
  3. func uniquePathsWithObstacles(obstacleGrid [][]int) int {
  4. n, m := len(obstacleGrid), len(obstacleGrid[0])
  5. dp := make([][]int, n + 1)
  6. for i := 0 ; i <= n ; i++ {
  7. dp[i] = make([]int, m + 1)
  8. }
  9. dp[0][0] = 1
  10. for i := 0 ; i < n ; i++ {
  11. for j := 0 ; j < m ; j++ {
  12. if obstacleGrid[i][j] == 0 {
  13. dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j]
  14. }
  15. }
  16. }
  17. return dp[n][m]
  18. }
  19. func main() {
  20. }
Add Comment
Please, Sign In to add comment