ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Multiplication Grid

Build a full multiplication table.

โจทย์

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 กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก