class Solution {
public:
vector<int> getRow(int rowIndex) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
vector<int> res(rowIndex+1,1);
if(rowIndex == 0)return res;
for(int i = 1; i <= rowIndex; i++)
{
int tmp = res[0];
for(int j = 1; j <= i-1; j++)
{
int kk = res[j];
res[j] = tmp+res[j];
tmp = kk;
}
}
return res;
public:
vector<int> getRow(int rowIndex) {
// IMPORTANT: Please reset any member data you declared, as
// the same Solution instance will be reused for each test case.
vector<int> res(rowIndex+1,1);
if(rowIndex == 0)return res;
for(int i = 1; i <= rowIndex; i++)
{
int tmp = res[0];
for(int j = 1; j <= i-1; j++)
{
int kk = res[j];
res[j] = tmp+res[j];
tmp = kk;
}
}
return res;
}
【版权声明】转载请注明出处:http://www.cnblogs.com/TenosDoIt/p/3436562.html