Problem
Draw a right-aligned pyramid like the one in Super Mario: row i (counting from 1) has height − i spaces followed by i # characters.
Implement pyramid_rows(height).
Input
height: The number of rows.
Output
Return the rows from top to bottom.
Constraints
0 ≤ height ≤ 50
Examples
Input:
height = 3
Expected output:
expected = [" #", " ##", "###"]
Input:
long long height = 3;
Expected output:
std::vector<std::string> expected = {" #", " ##", "###"};
Input:
long height = 3;
Expected output:
string[] expected = new string[] {" #", " ##", "###"};
Explanation
Rows are " #", " ##" and "###": each row has one more block and one less space.
Input:
height = 1
Expected output:
expected = ["#"]
Input:
long long height = 1;
Expected output:
std::vector<std::string> expected = {"#"};
Input:
long height = 1;
Expected output:
string[] expected = new string[] {"#"};
Explanation
A single row with one block: "#".
How to approach it
Try on your own first, then open one hint at a time.
Hint 1
Each row combines leading spaces with a growing run of hash characters.
Hint 2
Build rows one by one from top to bottom so the alignment stays correct.
Hint 3
If the height is zero, return no rows rather than an empty-looking pyramid.
Expected complexity
O(height^2) time, O(height^2) extra space
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.