Explanation

530.Print a Hollow Hourglass Star Pattern

Easy
Given n, return the 2n − 1 rows of a hollow hourglass: a solid top row of 2n − 1 stars, rows that narrow to a single-star waist, then rows that widen back out to a solid bottom row. Between the lids only the outline is drawn. The hourglass is a reverse pyramid stacked on a pyramid, sharing the middle row. A single number k = |n − 1 − r| + 1, built with the absolute valueAbsolute ValueThe distance of a number from zero, ignoring its sign: |−2| = |2| = 2., rises and falls in a V shape and drives both halves at once, so there is no need for two separate loops.

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