Untitled
unknown
plain_text
15 days ago
535 B
3
Indexable
Never
class Solution { public: vector<vector<int>> generate(int numRows) { //Beats 100.00% cin.tie(nullptr)->sync_with_stdio(0); vector<vector<int>> PascalTriangle; for (int i = 0; i < numRows; ++i) { vector<int> temp(i + 1, 1); for (int j = 1; j < i; ++j) { temp[j] = PascalTriangle[i - 1][j - 1] + PascalTriangle[i - 1][j]; } PascalTriangle.push_back(temp); } return PascalTriangle; } };
Leave a Comment