Explanation

498.Print a Right Half Pyramid Star Pattern

Easy
Given an integer n, return the n rows of a left-aligned star pyramid — row i has i stars, growing one star per row. The nested loopsNested LoopsAn outer loop over rows, an inner loop that appends exactly i stars for row i. version builds every row's stars one at a time. The string repetitionString Repetition per RowUsing a built-in repeat to build each differently-sized row directly, removing just the inner loop (the outer loop over rows still varies the length). version removes the inner loop specifically, since each row's content is just "repeat '*' i times" — still the same total O(n²) work (1+2+...+n stars), just expressed without the character-by-character detail.

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