Problem
Build an n × n multiplication table: the value in row i, column j (both counting from 1) is i × j.
Implement multiplication_grid(n).
Input
n: The table size.
Output
Return the table as a list of rows.
Constraints
0 ≤ n ≤ 20
Examples
Example 1
Input:
n = 3
Expected output:
expected = [
[1, 2, 3],
[2, 4, 6],
[3, 6, 9]
]
Input:
long long n = 3;
Expected output:
std::vector<std::vector<long long>> expected = {
{1, 2, 3},
{2, 4, 6},
{3, 6, 9}
};
Input:
long n = 3;
Expected output:
long[][] expected = new long[][] {
new long[] {1, 2, 3},
new long[] {2, 4, 6},
new long[] {3, 6, 9}
};
Explanation
Rows are [1, 2, 3], [2, 4, 6] and [3, 6, 9].
Example 2
Input:
n = 1
Expected output:
expected = [
[1]
]
Input:
long long n = 1;
Expected output:
std::vector<std::vector<long long>> expected = {
{1}
};
Input:
long n = 1;
Expected output:
long[][] expected = new long[][] {
new long[] {1}
};
Explanation
A 1×1 table holds only 1 × 1 = 1.
References
This challenge is adapted for CodeUtility. Follow the statement and constraints above.