![]() |
VOOZH | about |
We can utilize 'for' and 'while' loops to print a 180-degree rotation of a simple half-left pyramid in Java as follows:
Rows = 5
Output :
*
* *
* * *
* * * *
* * * * *
There are certain methods to Print the 180-rotated Simple Half-Left Pyramid mentioned below:
In this approach two for loops are utilized where, the first for loop identifies the number of rows while the second for loop identifies a number of columns. Here the values will be altered according to the first for loop. If j is greater than i then it will print the output otherwise it will print the space.
* * * * * * * * * * * * * * *
Explanation: The while loop checks for the condition until the condition becomes false. If the condition is true then it enters into the loop and executes the statements
* * * * * * * * * * * * * * *
Time complexity: O(n2) for given input of 'n' rows
Auxiliary space: O(1)