Visualize the Pyramid (centered triangle) pattern. See how leading spaces and odd-numbered stars per row create a symmetric shape.
A centered triangle. Each row is padded with spaces on the left so the stars form a symmetric pyramid shape.
For row i: spaces = n-1-i, stars = 2*i+1. Print the leading spaces first, then 2*i+1 stars.
The total width of every row is the same: (n-1-i) + (2i+1) + (n-1-i) = 2n-1. The pattern fits inside a 2n-1 wide box.