
You are given an integer 'n'.
Your task is to print a pattern of stars (*) and spaces () that forms an inverted, left-aligned pyramid of height 'n'.
The pattern should follow these rules:
1) The first (top) row must contain 'n' stars and 0 leading spaces. 2) Each subsequent row must contain one more leading space and one fewer star than the row above it. 3) The last (bottom) row must contain 'n-1' leading spaces and 1 star.The first line of input contains a single integer 'n'.
Print 'n' lines, each containing the appropriate number of leading spaces and stars to form the pyramid.
Do not print any trailing spaces after the stars on any line.
The total number of characters (spaces + stars) on each line will always be 'n'.
4
****
***
**
*
For n = 4, the pyramid has 4 rows:
- Row 1: 0 spaces, 4 stars
- Row 2: 1 space, 3 stars
- Row 3: 2 spaces, 2 stars
- Row 4: 3 spaces, 1 star
5
*****
****
***
**
*
The pattern for n = 5 follows the same logic, starting with 5 stars and decreasing by one in each subsequent row while the leading spaces increase.
The expected time complexity is O(n^2).
1 <= n <= 100
Time limit: 1sec
The expected time complexity is O(n^2).