//这种也是空间复杂度为O(K)的解法,就是边界有点难写
class Solution { public: vector<int> getRow(int rowIndex) { vector<int> res; res.push_back(1); if(rowIndex == 0) return res; res.push_back(1); if(rowIndex == 1) return res; for(int i=2;i <= rowIndex;i++){ res.push_back(0); int a = res[0]; int b = res[1]; for(int j=1;j < i;j++){ res[j] = a+b; a = b; b = res[j+1]; } res[i] = 1; } return res; } };