class Solution {
public:
vector<vector<int> > generate(int numRows) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector<vector<int> > res;
if (numRows <1) {
return res;
}
vector<int> first;
first.push_back(1);
res.push_back(first);
for(int i=1; i<numRows; i++) {
vector<int> rows;//rows.clear();
for (int j=0; j <= i; j++) {
if (j==0) {
rows.push_back(1);
} else if (j == i) {
rows.push_back(1);
} else {
rows.push_back(res[i-1][j-1]+res[i-1][j]);
}
}
res.push_back(rows);
}
return res;
}
};
public:
vector<vector<int> > generate(int numRows) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector<vector<int> > res;
if (numRows <1) {
return res;
}
vector<int> first;
first.push_back(1);
res.push_back(first);
for(int i=1; i<numRows; i++) {
vector<int> rows;//rows.clear();
for (int j=0; j <= i; j++) {
if (j==0) {
rows.push_back(1);
} else if (j == i) {
rows.push_back(1);
} else {
rows.push_back(res[i-1][j-1]+res[i-1][j]);
}
}
res.push_back(rows);
}
return res;
}
};