Hollow Diamond
Given a positive integer n, return a hollow diamond with 2n - 1 rows. The outline expands from one star to a middle row of width 2n - 1, then contracts…
Given a positive integer n, return a hollow diamond with 2n - 1 rows. The outline expands from one star to a middle row of width 2n - 1, then contracts symmetrically. Use one space for every blank position inside or before the outline. Do not add trailing spaces or a trailing newline.
- 1 ≤ n ≤ 10 - n is always a positive integer.
Example 1: input n = 3; output * * * * * * * *. The upper and lower halves share the widest row, so the result has five rows.
Example 2: input n = 1; output *. The smallest hollow diamond is one boundary star.
Category: Pattern Programs. Topic: pattern-programs. Difficulty: Easy. Patterns: math.