summaryrefslogtreecommitdiff
path: root/cpp/63.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-23 21:07:19 +0800
committercrupest <crupest@outlook.com>2021-02-23 21:07:19 +0800
commitd8f3b40085619cb680c8f227c65a1f5acc393223 (patch)
tree6a38e3a6c79276fc396259ef962d17236dbed569 /cpp/63.cpp
parentb0162802ad9723c678e495f29ca2f0fc0af2eff1 (diff)
downloadsolutions-d8f3b40085619cb680c8f227c65a1f5acc393223.tar.gz
solutions-d8f3b40085619cb680c8f227c65a1f5acc393223.tar.bz2
solutions-d8f3b40085619cb680c8f227c65a1f5acc393223.zip
Move leetcode solutions to subdir.
Diffstat (limited to 'cpp/63.cpp')
-rw-r--r--cpp/63.cpp44
1 files changed, 0 insertions, 44 deletions
diff --git a/cpp/63.cpp b/cpp/63.cpp
deleted file mode 100644
index 8e01c44..0000000
--- a/cpp/63.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <vector>
-
-using std::vector;
-
-class Solution
-{
-public:
- int uniquePathsWithObstacles(vector<vector<int>> &obstacleGrid)
- {
- if (obstacleGrid[0][0])
- return 0;
- obstacleGrid[0][0] = 1;
-
- int row = obstacleGrid.size();
- int col = obstacleGrid.front().size();
-
- for (int i = 1; i < row; i++)
- {
- obstacleGrid[i][0] = obstacleGrid[i - 1][0] && !obstacleGrid[i][0] ? 1 : 0;
- }
-
- for (int i = 1; i < col; i++)
- {
- obstacleGrid[0][i] = obstacleGrid[0][i - 1] && !obstacleGrid[0][i] ? 1 : 0;
- }
-
- for (int r = 1; r < row; r++)
- {
- for (int c = 1; c < col; c++)
- {
- if (obstacleGrid[r][c])
- {
- obstacleGrid[r][c] = 0;
- }
- else
- {
- obstacleGrid[r][c] = obstacleGrid[r - 1][c] + obstacleGrid[r][c - 1];
- }
- }
- }
-
- return obstacleGrid[row - 1][col - 1];
- }
-};