diff --git a/algorithms/cpp/uniquePaths/uniquePaths.II.cpp b/algorithms/cpp/uniquePaths/uniquePaths.II.cpp index 782c10dda..477c29f82 100644 --- a/algorithms/cpp/uniquePaths/uniquePaths.II.cpp +++ b/algorithms/cpp/uniquePaths/uniquePaths.II.cpp @@ -30,11 +30,15 @@ using namespace std; //As same as DP solution with "Unique Path I", just need to consider the obstacles. -int uniquePathsWithObstacles(vector > &obstacleGrid) { - vector< vector > v = obstacleGrid; +int uniquePathsWithObstacles(vector>& obstacleGrid) { + + int row =obstacleGrid.size(); + int col = obstacleGrid[0].size(); + vector> v (row, vector(col, 0)); + unsigned int max=0; - for (int i=0; i>& obstacleGrid) { int row = obstacleGrid.size(); int col = obstacleGrid[0].size(); - vector< vector > dp (row, vector(col, 0)); + vector< vector > dp (row, vector(col, 0)); dp[0][0] = obstacleGrid[0][0] ? 0 : 1; for (int r=1; r