import java.util.*;
public class Solution {
public int uniquePaths (int rowCount, int colCount) {
// 使用排列组合公式
// 从rowCount+colCount-2个元素中选出rowCount-1个
// 初始化
long n = (rowCount + colCount - 2);
long m = (rowCount - 1);
// 按公式计算结果
long ans = 1;
for (int i = 1; i <= m; i++) {
ans = ans * (n - m + i) / i ;
}
return (int)ans;
}
}



京公网安备 11010502036488号