Explanation

524.Print a Hollow Diamond Pattern

Easy
Given n, return the 2n rows of a hollow diamond: the same outline as the Diamond pattern, but with only the border stars kept and the inside filled with spaces. Rows have no trailing spaces. The trick that keeps the code short is a single "size" number k for each row that rises 1, 2, …, n and then falls n, …, 1 — one formula covers both halves. Hollowing is then an edge checkEdge CheckTesting whether a position is the first or last in its row, and printing a star only there.: the first and last positions of a row are stars, everything between them is a space.

Example 1:

Input: n = 3

Output: [" *"," * *","* *","* *"," * *"," *"]

Example 2:

Input: n = 1

Output: ["*","*"]

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ n ≤ 20

n =

3