Loading problem…
Pick the best time and space complexity.
function countPaths(rows, cols) { const dp = Array.from({ length: rows }, () => Array(cols).fill(1)) for (let r = 1; r < rows; r++) { for (let c = 1; c < cols; c++) { dp[r][c] = dp[r - 1][c] + dp[r][c - 1] } } return dp[rows - 1][cols - 1] }