mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-12-08 19:06:00 +00:00
14 lines
364 B
JavaScript
14 lines
364 B
JavaScript
import pascalTriangle from '../../math/pascal-triangle/pascalTriangle';
|
|
|
|
/**
|
|
* @param {number} width
|
|
* @param {number} height
|
|
* @return {number}
|
|
*/
|
|
export default function uniquePaths(width, height) {
|
|
const pascalLine = width + height - 2;
|
|
const pascalLinePosition = Math.min(width, height) - 1;
|
|
|
|
return pascalTriangle(pascalLine)[pascalLinePosition];
|
|
}
|