Explanation

532.Print a Palindrome Number Pyramid

Easy
Given n (at most 9, so every number is a single digit), return n centred rows where row i counts up from 1 to i and back down to 1 — for example "12321" for i = 3. Every row is a palindromePalindromeA sequence that reads the same forwards and backwards, such as 12321., and the rows grow by two characters each time, which is why they stack into a pyramid once n − i leading spaces are added. The second solution uses the palindrome property directly: build the rising half once and mirror it.

Example 1:

Input: n = 4

Output: [" 1"," 121"," 12321","1234321"]

Example 2:

Input: n = 1

Output: ["1"]

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ n ≤ 9

n =

4