Practice/mediumHollow Diamond
⏱ 00:00
Best: 0/100
Complex Spacing & Hollow GeometryTarget Time: 15 mins

Hollow Diamond

Given an integer N, print a hollow diamond pattern with (2*N - 1) rows. Only the outer border of the diamond contains stars (*), and the inside is completely hollow.

Input Format
A single integer N.
Output Format
Print 2*N - 1 rows of a hollow diamond.
Constraints:1 <= N <= 15
Concepts Required:
Dual pyramid reflectionInterior space formula (2*i - 3)Outer space formula (N - i)
Expected Pattern PreviewASCII Monospace
    *
   * *
  *   *
 *     *
*       *
 *     *
  *   *
   * *
    *

Notice how character spacing and row counts scale systematically based on the input N.

Concrete Examples

Example 1
Input:
5
Output:
    *
   * *
  *   *
 *     *
*       *
 *     *
  *   *
   * *
    *

Explanation: The diamond has 9 rows with stars on the border.

← Back to All Challenges