問題
Build a number triangle: row i (counting from 1) lists the numbers 1, 2, …, i.
Implement number_triangle(rows).
Input
rows: The number of rows.
Output
Return the triangle as a list of rows.
制約
0 ≤ rows ≤ 30
例
例 1
入力:
rows = 3
期待される出力:
expected = [
[1],
[1, 2],
[1, 2, 3]
]
入力:
long long rows = 3;
期待される出力:
std::vector<std::vector<long long>> expected = {
{1},
{1, 2},
{1, 2, 3}
};
入力:
long rows = 3;
期待される出力:
long[][] expected = new long[][] {
new long[] {1},
new long[] {1, 2},
new long[] {1, 2, 3}
};
解説
Rows are [1], [1, 2] and [1, 2, 3].
例 2
入力:
rows = 0
期待される出力:
expected = []
入力:
long long rows = 0;
期待される出力:
std::vector<std::vector<long long>> expected = {};
入力:
long rows = 0;
期待される出力:
long[][] expected = new long[][] {};
解説
No rows were requested, so the triangle is empty.
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。