You are given an integer n, representing the number of rows to generate in Pascal’s Triangle.
In Pascal’s Triangle:
• The first and last element of each row is always 1.
• Every other element is the sum of the two numbers directly above it in the previous row.
Your task is to return a 2D list representing the first n rows of Pascal’s Triangle.
Input: n = 6
Output: [ [1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1] ]
Input: n = 3
Output: [ [1], [1, 1], [1, 2, 1] ]
Accepted:
Submission: