Here is my solution and explanation:

```
public List<Integer> getRow(int rowIndex) {
ArrayList<Integer> result = new ArrayList<>();
double s = 1;
for(int i = 0;i<=rowIndex;i++){
if(i==0||i==rowIndex){
result.add(1);
continue;
}
// why do this math??
s = (rowIndex-i+1)*s/i;
result.add((int)s);
}
return result;
}
```

and here is my explanation:

- why s use double type : first I use int ,but when rowindex gets to 30 ,when index gets to 15,s will overflow , so ,I use double.

But I was confused with the line that I comment，why this will calculate the right index ?