Given an integer n, return the n-th row of Pascal's triangle. The rows are 1-indexed, meaning n=1 corresponds to the first non-empty row. If n is 0 or less, an empty array [] should be returned.
In Pascal's triangle, each number is the sum of the two numbers directly above it. The first and last numbers in each row are always 1.
For example:
[] (by definition for n <= 0)[1][1, 1][1, 2, 1][1, 3, 3, 1][1, 4, 6, 4, 1]1
[1]
The 1st row of Pascal's triangle is simply [1].
3
[1, 2, 1]
To get the 3rd row, we derive it from the 2nd row [1, 1]. The elements are 1, (1+1)=2, 1.
5
[1, 4, 6, 4, 1]
The 5th row is calculated from the 4th row [1, 3, 3, 1]. The elements are 1, (1+3)=4, (3+3)=6, (3+1)=4, 1.
0
[]
As per the problem description, for n less than or equal to 0, an empty array should be returned.
1
[1]