```
class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<vector<int> > rows {vector<int>(rowIndex + 1), vector<int>(rowIndex + 1)};
rows[0][0] = 1;
for (int i = 1; i <= rowIndex; ++i) {
rows[i & 1][0] = 1;
for (int j = 1; j < i; ++j) {
rows[i & 1][j] = rows[(i - 1) & 1][j - 1] + rows[(i - 1) & 1][j];
}
rows[i & 1][i] = 1;
}
return rows[rowIndex & 1];
}
};
```