<commit_before>package leetcode;

/**
 * https://leetcode.com/problems/unique-paths-ii/
 */
public class Problem63 {
    public int uniquePathsWithObstacles(int[][] obstacleGrid) {
        // TODO: implement this
        return 0;
    }
    
    public static void main(String[] args) {
        Problem63 prob = new Problem63();
        int[][] grid = new int[][]{
            new int[]{0, 0, 0},
            new int[]{0, 1, 0},
            new int[]{0, 0, 0}
        };
        System.out.println(prob.uniquePathsWithObstacles(grid));<commit_msg>Update problem 63 (too slow)<commit_after>package leetcode;

/**
 * https://leetcode.com/problems/unique-paths-ii/
 */
public class Problem63 {
    public int uniquePathsWithObstacles(int[][] obstacleGrid) {
        if (obstacleGrid.length == 0) {
            return 0;
        }
        return findPaths(obstacleGrid, obstacleGrid.length-1, obstacleGrid[0].length-1,
            0, 0);
    }
    
    private int findPaths(int[][] grid, int destRow, int destCol, int row, int col) {
        if (row == destRow && col == destCol) {
            return 1;
        } 
        if (row > destRow || col > destCol) {
            return 0;
        }
        if (grid[row][col] == 1) {
            return 0;
        }
        int a = findPaths(grid, destRow, destCol, row+1, col);
        int b = findPaths(grid, destRow, destCol, row, col+1);
        return a + b;
    }
    
    public static void main(String[] args) {
        Problem63 prob = new Problem63();
        int[][] grid = new int[][]{
            new int[]{0, 0, 0},
            new int[]{0, 1, 0},
            new int[]{0, 0, 0},
            new int[]{0, 0, 0},
            new int[]{0, 0, 0},
        };
        System.out.println(prob.uniquePathsWithObstacles(grid));
{'fraction_non_alphanumeric': 0.1459977452085682, 'fraction_numerical': 0.029312288613303268, 'mean_word_length': 1.919407894736842, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '959376', 'n_tokens_mistral': 594, 'n_tokens_neox': 553, 'n_words': 147}