1 class Solution { 2 public: 3 vector<int> getRow(int rowIndex) { 4 vector<vector<int>> tri; 5 if(rowIndex==0) 6 { 7 vector<int> c; 8 c.push_back(1); 9 return c; 10 } 11 vector<int> b; 12 b.push_back(0); 13 b.push_back(1); 14 b.push_back(0); 15 tri.push_back(b); 16 17 for(int i=1;i<=rowIndex;i++) 18 { 19 vector<int> a; 20 a.push_back(0); 21 for(int j=1;j<=i+1;j++) 22 a.push_back(tri[i-1][j-1]+tri[i-1][j]); 23 a.push_back(0); 24 tri.push_back(a); 25 } 26 vector<int> res; 27 for(int i=1;i<=rowIndex+1;i++) 28 { 29 res.push_back(tri[rowIndex][i]); 30 } 31 32 return res; 33 34 } 35 };