MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / generate

Method generate

-118-Pascal's-triangle/pascals_triangle.cpp:6–17  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4class Solution {
5public:
6 vector<vector<int>> generate(int numRows) {
7 vector<vector<int>> triangle;
8 triangle.reserve(numRows);
9 for (int r = 0; r < numRows; ++r) {
10 vector<int> row(r + 1, 1);
11 for (int c = 1; c < r; ++c) {
12 row[c] = triangle[r - 1][c - 1] + triangle[r - 1][c];
13 }
14 triangle.push_back(move(row));
15 }
16 return triangle;
17 }
18};
19
20// Helper main for quick local testing

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected