Look at Pascal's triangle, the pyramid of numbers. Every row begins with 1 and ends with 1. Each number between the ends is the sum of the two numbers diagonally above it.
Rows are counted from 0. Row 0 is [1], row 1 is [1,1], and row 2 is [1,2,1].
Given a whole number rowIndex, return only that one row, as a list.
Examples
Example 1:
Input: rowIndex = 4
Output: [1,4,6,4,1]
Explanation: Row 3 is [1,3,3,1]. The middle numbers of row 4 are 1 + 3 = 4, 3 + 3 = 6 and 3 + 1 = 4.
Example 2:
Input: rowIndex = 6
Output: [1,6,15,20,15,6,1]
Explanation: Row 5 is [1,5,10,10,5,1]. The middle numbers of row 6 are 1 + 5 = 6, 5 + 10 = 15 and 10 + 10 = 20. The rest repeat in reverse.
Example 3:
Input: rowIndex = 9
Output: [1,9,36,84,126,126,84,36,9,1]
Explanation: Row 9 has 10 numbers. The row reads the same from both ends.