{"size": 814, "ext": "js", "max_stars_repo_path": "javascript/062_need_optimize.js", "max_stars_repo_name": "ee06b056/Leetcode", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "javascript/062_need_optimize.js", "max_issues_repo_name": "ee06b056/Leetcode", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "javascript/062_need_optimize.js", "max_forks_repo_name": "ee06b056/Leetcode", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.4210526316, "max_line_length": 63, "alphanum_fraction": 0.4127764128}
/**
 * @param {number} m
 * @param {number} n
 * @return {number}
 */
var uniquePaths = function(m, n) {
    let row = Array(m).fill(0), matrix = [];
    for (let i = 0; i < n; i++) {
        matrix.push(row.slice());
    }
    for (let i = 0; i < m; i++) {
        matrix[0][i] = 1;
    }
    for (let i = 0; i < n; i++) {
        matrix[i][0] = 1;
    }
    for (let i = 1; i < n; i++) {
        for (let j = 1; j < m; j++) {
            matrix[i][j] = matrix[i][j - 1] + matrix[i - 1][j];
        }
    }
    return matrix[n - 1][m - 1];
};


var uniquePaths2 = function (m, n) {
    let row = Array(m).fill(1);
    for (let i = 1; i < n; i++) {
        for (let j = 1; j < m; j++) {
            row[j] = row[j - 1] + row[j];
        }
    }
    return row[row.length - 1];
}



console.log(uniquePaths2(3, 2));