# Leetcode 62. Unique Paths ###### tags: `Leetcode(C++)` 題目 : https://leetcode.com/problems/unique-paths/ 。 想法 : 爬樓梯的DP唷。 path[i][j] = path[i-1][j] + path[i][j-1]; 時間複雜度 : O(n*m)。 程式碼 : ``` class Solution { public: int uniquePaths(int m, int n) { int dp[110][110]={0}; dp[0][0]=1; for(int i=0 ; i<m ; i++){ for(int j=0 ; j<n ; j++){ if(i-1 >= 0) dp[i][j] += dp[i-1][j]; if(j-1 >= 0) dp[i][j] += dp[i][j-1]; } } return dp[m-1][n-1]; } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up