DSA problem
Inverted Pyramid of Stars
Given an integer N, print an inverted centered pyramid of stars with N rows.
This is the upside-down version of the standard pyramid. The first row has 2 * N - 1 stars with no leading spaces, and the last row has a single star with N - 1 leading spaces. For row i you print i - 1 spaces followed by 2 * (N - i) + 1 stars.
It reinforces the same lesson as the pyramid: once you understand how row number, spaces, and stars relate, you can generate any symmetric shape by tweaking the formula.
Examples
Example 1
Input:
N = 5Output:
*********
*******
*****
***
*Explanation: Row i has (i - 1) leading spaces and (2 * (N - i) + 1) stars, shrinking to a point.
Constraints
- 1 <= N <= 100
3 hints and a full solution walkthrough with step-by-step visualizations are available in the practice editor.