Explanation

531.Print Pascal's Triangle as a Pattern

Easy
Given n, return the first n rows of Pascal's triangle as centred text: row i (counting from 0) has n − 1 − i leading spaces, followed by its values separated by single spaces. Every edge value is 1 and every inner value is the sum of the two values above it. Those values are the binomial coefficientsBinomial CoefficientC(i, j): the number of ways to choose j items from i. Row i of Pascal's triangle lists C(i, 0) to C(i, i)., which also lets each value be computed from its left neighbour. The single space between numbers is what produces the triangle shape when the rows are printed.

Example 1:

Input: n = 4

Output: [" 1"," 1 1"," 1 2 1","1 3 3 1"]

Example 2:

Input: n = 1

Output: ["1"]

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ n ≤ 10

n =

4