Simple combinatorics, but I didn't realize the number could be extremely large to fit in integer type.

```
class Solution {
public:
int uniquePaths(int m, int n) {
long long p = 1;
if (--m < --n) swap(m, n);
for (uint i = 1; i <= n; i++) p *= ++m, p /= i;
return p;
}
};
```