The answer
No. The number of characters printed is exactly the same, just in a different order. The time complexity remains O(N^2).
No. The number of characters printed is exactly the same, just in a different order. The time complexity remains O(N^2).
Take the exact code used for a normal pyramid, and simply change the outer loop to count down from N to 1 instead of 1 to N.
If counting rows 1 to N, the leading spaces increase according to the formula: row - 1.
If counting rows 1 to N, the stars decrease according to the formula: 2 * (N - row) + 1.
Browse all our FAQs or reach out to our support team
Your learning library
Find your next course. Build something great.
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success
Success