public int uniquePathsWithObstacles(int[][] obstacleGrid) {
		int m = obstacleGrid.length;
		if (m < 1)
			return 0;
		int n = obstacleGrid[0].length;
		if (n < 1)
			return 0;
		if (obstacleGrid[0][0] != 0)
			return 0;
		int[] dp = new int[n];
		dp[0] = 1;
		// Initialize first row
		for (int j = 1; j < n; j++) {
			if (obstacleGrid[0][j] == 1)
				dp[j] = 0;
			else
				dp[j] = dp[j - 1];
		}
		for (int i = 1; i < m; i++) {
			dp[0] = obstacleGrid[i][0] == 0 ? dp[0] : 0;
			for (int j = 1; j < n; j++) {
				dp[j] = obstacleGrid[i][j] == 0 ? dp[j] + dp[j - 1] : 0;
			}
		}
		return dp[n - 1];
	}