Explanation

509.Print a Full Star Pyramid

Easy
Given an integer n, return the n rows of a centered, symmetric star pyramid — row i has (n − i) leading spaces, then (2i − 1) stars. Unlike the Right Half Pyramid (which grows by 1 star per row and is left-aligned), this pyramid grows by 2 stars per row — one on each side — which is exactly what keeps it centered and symmetric. The nested loopsNested LoopsAn outer loop over rows, one inner loop for the leading spaces, another for the (2i-1) stars. version builds each half explicitly; the built-in repetitionBuilt-in RepetitionBuilding the space-padding and the stars each with a repeat call, then concatenating the two pieces. version replaces both inner loops with two built-in calls.

Example 1:

Input: n = 4

Output: [" *"," ***"," *****","*******"]

Example 2:

Input: n = 1

Output: ["*"]

+ 1 hidden test case run on Submit.

Constraints:

  • ●1 ≤ n ≤ 20

n =

4