```
vector<int> getRow(int rowIndex) {
vector<int> res(rowIndex+1,1);
for (int i = 2; i <= rowIndex; ++i) {
int prev = res[0];
for (int j = 1; j < i; ++j) {
int temp = prev+res[j];
prev = res[j];
res[j] = temp;
}
}
return res;
}
```