@@ -0,0 +1,1100 @@
+// Follow up for %22Unique Paths%22:%0A%0A// Now consider if some obstacles are added to the grids. How many unique paths would there be?%0A%0A// An obstacle and empty space is marked as 1 and 0 respectively in the grid.%0A%0A// For example,%0A// There is one obstacle in the middle of a 3x3 grid as illustrated below.%0A%0A// %5B%0A//   %5B0,0,0%5D,%0A//   %5B0,1,0%5D,%0A//   %5B0,0,0%5D%0A// %5D%0A// The total number of unique paths is 2.%0A%0A// Note: m and n will be at most 100.%0A%0Apublic class Solution %7B%0A    public int uniquePathsWithObstacles(int%5B%5D%5B%5D obstacleGrid) %7B%0A        int row = obstacleGrid.length;%0A        %0A        if(row == 0) return 0;%0A        %0A        int col = obstacleGrid%5B0%5D.length;%0A%0A        int%5B%5D%5B%5D paths = new int%5Brow%5D%5Bcol%5D;%0A%0A%09%09for(int i = 0; i %3Crow; i++)%7B%0A%09%09%09if(obstacleGrid%5Bi%5D%5B0%5D == 1) break;%0A%0A%09%09%09paths%5Bi%5D%5B0%5D = 1;%0A%09%09%7D%0A%0A%09%09for(int j = 0; j %3C col; j++)%7B%0A%09%09%09if(obstacleGrid%5B0%5D%5Bj%5D == 1) break;%0A%0A%09%09%09paths%5B0%5D%5Bj%5D = 1;%0A%09%09%7D%0A%0A%09%09for(int i = 0; i %3C row; i++)%7B%0A%09%09%09for(int j = 0; j %3C col; j++)%7B%0A%09%09%09%09if(obstacleGrid%5Bi%5D%5Bj%5D == 1) continue;%0A%09%09%09%09paths%5Bi%5D%5Bj%5D = paths%5Bi - 1%5D%5Bj%5D + paths%5Bi%5D%5Bj - 1%5D;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return paths%5Brow - 1%5D%5Bcol - 1%5D;%0A    %7D%0A%7D

add unique paths ii solution