I saw many answers are using 2-D vector which is unnecessary. Check my 1-D vector solution
\n    int uniquePathsWithObstacles(vector > &obstacleGrid) {\n        int width = obstacleGrid[0].size();\n        vector result(width, 0);\n        result[0] =
\n    int uniquePathsWithObstacles(vector<vector<int> > &obstacleGrid) {\n        int width = obstacleGrid[0].size();\n        vector<int> result(width, 0);\n        result[0] = 1;\n\n        for (int i = 0; i <  obstacleGrid.size(); ++i) {\n            for (int j = 0; j < width; ++j) {\n                if (obstacleGrid[i][j] == 1)\n                    result[j] = 0;\n                else if (j > 0)\n                    result[j] += result[j-1];\n            }\n        }\n        return result[width-1];\n    }
[]