时间复杂度(O(n2))
class Solution {
public:
int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {
if(obstacleGrid.size()==0||obstacleGrid.back().size()==0)return 0;
vector<int> vec;
for(int j=0;j<obstacleGrid[0].size();++j)
if(obstacleGrid[0][j]==1) vec.push_back(0);
else if(j>0) vec.push_back(vec.back());
else vec.push_back(1);
for(int i=1;i<obstacleGrid.size();++i)
for(int j=0;j<obstacleGrid[i].size();++j)
if(obstacleGrid[i][j]==1)vec[j] = 0;
else if(j>0)vec[j] += vec[j-1];
return vec.back();
}
};