triangle
to hold the rows of Pascal's Triangle.[1]
to triangle
.numRows
:
a. Create a new row list with the first element as 1
.
b. For each element from the second to the second last in the previous row, add the sum of the element and the element before it to the new row.
c. Append 1
to the new row to complete it.
d. Add the new row to triangle
.triangle
after all rows have been added.