Watch a mirrored right triangle print in stars: spaces first, then stars, so the triangle stands against the right edge. Step through the nested loop cell by cell.
About this algorithm
The mirrored triangle is the right triangle pushed against the right edge: row i still has i + 1 stars, but spaces come first, so the long side of the triangle stands on the right. It is the first pattern where a row starts with blanks.
Do it right after the right triangle. The star count per row is the same; what changes is where the stars start. That idea, a row that begins with spaces, is what the pyramid builds on next.
The page uses n rows and n columns, and visits every cell of each row from left to right.
Row i has n - 1 - i spaces in front: n - 1 on the first row, none on the last.
Every column from n - 1 - i to the right edge is a star, which is i + 1 stars on row i.
A 5 by 5 grid. Row 0 is four spaces and one star, row 4 is five stars. Stars per row: 1, 2, 3, 4, 5, which is 15 stars and 10 spaces in 25 cells.
The right triangle tests j <= i, counting columns from the left. The mirrored triangle tests j >= n - 1 - i, which counts the same number of columns from the right. Swapping j for n - 1 - j turns either rule into the other.
Printing only the stars, without the spaces in front, gives the plain right triangle back. The leading spaces are what moves the shape, so the loop has to print them.
Time: each of the n² cells is tested once. Space: the test needs only i, j and n.