From 19658033ed6c37867f269feab640d4188716aacc Mon Sep 17 00:00:00 2001 From: ehds Date: Tue, 26 Feb 2019 20:43:05 +0800 Subject: [PATCH] fix uniquePaths.II solution --- algorithms/cpp/uniquePaths/uniquePaths.II.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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