Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5701 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 938 |
@bt8816103042 | 739 |
@SHOAIBVIJAPURE | 428 |
@codeantik | 412 |
@SherlockHolmes3 | 407 |
@neverevergiveup | 348 |
@mahlawatep | 347 |
@shalinibhataniya1097 | 343 |
@murarry3625 | 333 |
@saiujwal13083 | 326 |
@rohitanand | 314 |
Complete Leaderboard |
Given a n*m matrix A and a p*q matrix B, their Kronecker product C = A tensor B, also called their matrix direct product, is an (np)*(mq) matrix.
A tensor B
=
|a11B a12B|
|a21B a22B|
=
|a11b11 a11b12 a12b11 a12b12|
|a11b21 a11b22 a12b21 a12b22|
|a11b31 a11b32 a12b31 a12b32|
|a21b11 a21b12 a22b11 a22b12|
|a21b21 a21b22 a22b21 a22b22|
|a21b31 a21b32 a22b31 a22b32|
Example 1:
Input:
n = 2, m = 2
p = 2, q = 2
A = {{1, 2},
{3, 4}}
B = {{0, 5},
{6, 7}}
Output: {{0, 5, 0, 10},
{6, 7, 12, 14},
{0, 15, 0, 20},
{18, 21, 24, 28}}
Explaination: If the multiplication process
is followed then this will be the answer.
Your Task:
You do not need to read input or print anything. Your task is to complete the function kroneckerProduct() which takes n, m, p, q and A and B as input parameters and returns the resultant matrix.
Expected Time Complexity: O(n*m*p*q)
Expected Auxiliary Space: O(n*m*p*q)
Constraints:
1 ≤ n, m, p, q ≤ 20
1 ≤ A[i][j], B[i][j] ≤ 100
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes