Skip to content

Commit

Permalink
Time: 0 ms (100%), Space: 4 MB (68.12%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
hovanhoa committed Dec 30, 2024
1 parent 8787a09 commit 862a7b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 0062-unique-paths/0062-unique-paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ func uniquePaths(m int, n int) int {
dp := make([][]int, m)
for i := range dp {
dp[i] = make([]int, n)
}
}

for i := range dp {
for j := range dp[i] {
if i == 0 || j == 0 {
dp[i][j] = 1
} else {
dp[i][j] = dp[i][j-1] + dp[i-1][j]
dp[i][j] = dp[i-1][j] + dp[i][j-1]
}
}
}

return dp[m-1][n-1]
}
}

0 comments on commit 862a7b3

Please sign in to comment.