![]() |
VOOZH | about |
Write to program to print the pyramid pattern formed of stars
Example :
Input: n = 6 Output: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
We strongly recommend you to minimize your browser and try this yourself first.
The idea is to use two for loops for every part of the pyramid. The two parts may be classified as upper part and lower part
Output :
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Time complexity: O(n2)
Auxiliary Space: O(1)