0119.cpp (434B)
1 class Solution { 2 public: 3 vector<int> getRow(int rowIndex) { 4 vector<vector<int>> res; 5 6 for (int i = 0; i <= rowIndex; i++) { 7 vector<int> row; 8 row.push_back(1); 9 for (int j = 1; j < i; j++) 10 row.push_back(res[i - 1][j - 1] + res[i - 1][j]); 11 if (i != 0) row.push_back(1); 12 res.push_back(row); 13 } 14 return res[rowIndex]; 15 } 16 };