let uniquePaths = function(m, n) {
let results = new Set();
function getPath(row, col, path = '') {
if (row >= m && col >= n) {
results.add(path);
return;
}
if (row === m) {
// go right if at the bottom row
getPath(row, col + 1, path + 'R');
}
else if (col === n) {
// go down if at the end column
getPath(row + 1, col, path + 'D');
}
else {
// go down and go right
getPath(row, col + 1, path + 'R');
getPath(row + 1, col, path + 'D');
}
}
getPath(1, 1, 'S');
return results.size;
};