Star Hill
Given a positive integer n, return a left-aligned star hill with 2n-1 rows. Star counts rise from 1 through n, then fall from n-1 through 1 without repeating…
Given a positive integer n, return a left-aligned star hill with 2n-1 rows. Star counts rise from 1 through n, then fall from n-1 through 1 without repeating the peak. Add no spaces or trailing newline; join adjacent rows with one newline character.
- 1 ≤ n ≤ 10 - n is always a positive integer. - The output contains exactly 2n-1 rows.
Example 1: input n = 3; output * ** *** ** *. Widths rise 1, 2, 3 and fall 2, 1 without duplicating the peak.
Example 2: input n = 1; output *. The two phases collapse to one row.
Category: Pattern Programs. Topic: pattern-programs. Difficulty: Easy. Patterns: math.