class Solution {
public:
int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {
if (obstacleGrid.empty()) return 0;
unsigned int res[101][101];
memset(res, 0, sizeof(res));
int rowCount = obstacleGrid.size();
int colCount = obstacleGrid[0].size();
for (int i = 0; i < rowCount && obstacleGrid[i][0] == 0; ++i) {
res[i][0] = 1;
}
for (int j = 0; j < colCount && obstacleGrid[0][j] == 0; ++j) {
res[0][j] = 1;
}
for (int i = 1; i < rowCount; ++i) {
for (int j = 1; j < colCount; ++j) {
if (obstacleGrid[i][j] == 0) {
res[i][j] = res[i - 1][j] + res[i][j - 1];
}
}
}
return res[rowCount - 1][colCount - 1];
}
};