标签:i++ 版权 uniq tor etc leetcode with tac cto
class Solution { public: int uniquePathsWithObstacles(vector<vector<int> >& a) { int i,j; int n = a.size(),m = a[0].size(); vector<vector<int> > dp; dp.resize(n+1); for(i = 0; i<=n; i++) dp[i].resize(m+1); dp[0][0] = !a[0][0]; for(i = 0; i<n; i++) { for(j = 0; j<m; j++) { if(i==0&&j==0) continue; if(a[i][j]==1) { dp[i][j] = 0; continue; } if(i == 0) { dp[i][j]=dp[i][j-1]; continue; } if(j == 0) { dp[i][j]=dp[i-1][j]; continue; } dp[i][j]=dp[i-1][j]+dp[i][j-1]; } } return dp[n-1][m-1]; } };
[LeedCode OJ]#63 Unique Paths II
标签:i++ 版权 uniq tor etc leetcode with tac cto
原文地址:http://www.cnblogs.com/lxjshuju/p/7114776.html