This solution is based on some properties of nCr:

- C(n, r) = C(n, n - r)
- C(n, r) = C(n, r - 1) * (n - r + 1) / r
- C(n, 0) = 1

I used recursive form and long type to prevent some overflow problems.

Ref: https://en.wikipedia.org/wiki/Combination#Number_of_k-combinations

```
public class Solution {
public List<Integer> getRow(int rowIndex) {
List<Integer> res = new ArrayList();
if (rowIndex < 0)
return res;
for (int i = 0; i <= rowIndex; i++) {
res.add((int)combN(rowIndex, i));
}
return res;
}
private long combN(int n, int r) {
if (r > n / 2)
return combN(n, n - r);
if (r == 0)
return 1;
return combN(n, r - 1) * (n - r + 1) / r;
}
}
```