समस्या
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.
सीमाएँ
0 ≤ n ≤ 20
उदाहरण
उदाहरण 1
इनपुट:
n = 3
अपेक्षित आउटपुट:
expected = [
[1, 2, 3],
[2, 4, 6],
[3, 6, 9]
]
इनपुट:
long long n = 3;
अपेक्षित आउटपुट:
std::vector<std::vector<long long>> expected = {
{1, 2, 3},
{2, 4, 6},
{3, 6, 9}
};
इनपुट:
long n = 3;
अपेक्षित आउटपुट:
long[][] expected = new long[][] {
new long[] {1, 2, 3},
new long[] {2, 4, 6},
new long[] {3, 6, 9}
};
व्याख्या
Rows are [1, 2, 3], [2, 4, 6] and [3, 6, 9].
उदाहरण 2
इनपुट:
n = 1
अपेक्षित आउटपुट:
expected = [
[1]
]
इनपुट:
long long n = 1;
अपेक्षित आउटपुट:
std::vector<std::vector<long long>> expected = {
{1}
};
इनपुट:
long n = 1;
अपेक्षित आउटपुट:
long[][] expected = new long[][] {
new long[] {1}
};
व्याख्या
A 1×1 table holds only 1 × 1 = 1.
संदर्भ
यह चुनौती CodeUtility के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।