In Pascal's triangle, each number is the sum of the two numbers directly
Example 1:
Input: numRows = 5 Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
Solution:
class Solution {
public:
vector<vector<int>> generate(int numRows) {
std::vector<std::vector<int>> result;
for(int i=0; i < numRows; i++){
std::vector<int> row(i + 1, 1);
for(int j = 1; j < i; j++){
row[j] = result[i - 1][j - 1] + result[i - 1][j];
}
result.push_back(row);
}
return result;
}
};