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

Hollow Pyramid

Given an integer N, print a hollow pyramid of N rows. The perimeter lines (first row apex, bottom row base, left edge, and right edge) contain stars (*), while the interior contains spaces.

Input Format
A single integer N.
Output Format
Print N rows forming a hollow pyramid.
Constraints:1 <= N <= 20
Concepts Required:
Interior hollow spacingBase edge boundary checkCentered triangular geometry
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: Row 1 has 1 star. Rows 2-4 have 2 stars separated by spaces. Row 5 is completely filled with 9 stars.

← Back to All Challenges