503.Print an Increasing Number Triangle
Easy
Given an integer
n, return the n rows of a number triangle — row i counts from 1 up to i, space-separated.
This is the Right Half Pyramid's shape, filled with counting numbers instead of stars. The nested loopsNested LoopsAn outer loop over rows, an inner loop counting from 1 to i and appending each number. version builds each row number by number. The range + joinRange + JoinGenerating the range 1 to i directly, then joining it with spaces — no manual index or space bookkeeping. version describes the same row as a single range-and-join expression.
Example 1:
Input: n = 3
Output: ["1","1 2","1 2 3"]
Example 2:
Input: n = 1
Output: ["1"]
+ 1 hidden test case run on Submit.
Constraints:
- ●
1 ≤ n ≤ 9
n =
3