/* I can use two pointers to make this happen, The ith entry of the row contains 'i' elements the first and last entries of the list is '1' 1 -> 1 2 -> 2 3 -> 3 4 -> 4 */ class Solution { public: vector> generate(int numRows) { // Create the triangle vector> pascal; // Iterate over the triangle to fill it for(int k = 0; k < numRows; k++) { // Create a new row, with first and last entry as 1 vector row = vector(k+1, 1); // push the row pascal.emplace_back(row); // If length is greater than 2 if(k >= 2) { // Use two pointers to fill the array, // left will start for the 0th index, right will go upto the last index int l = 0, r = 1; while(r != k) { pascal[k][l+1] = pascal[k-1][l] + pascal[k-1][r]; l++; r++; } } } return pascal; } };