0

Kronecker Product

Unsolved
Linear Algebra

Difficulty: 3 | Problem written by Mr. Umair
Problem reported in interviews at

Amazon
Apple
Facebook
Google
Netflix

The Kronecker Product is a tensor product in matrix which can be calculated from vectors or matrices by generalizing the concept of the outer product. Given two 2D NumPy array, your function should return a 2D array containing the Kronecker Product.

Input:

Matrix A = [[0, 1, 2],[3, 4, 5],[6, 7,8]]

Matrix B = [[85, 77, 30], [ 2,  9, 34], [22, 14, 96]]

Output:

Resultant Matrix =  [[0, 0, 0, 0, 0, 0, 0, 0, 0],

                                 [0, 0, 0, 0, 22, 44, 0, 0, 0],

                                 [0, 255, 6, 66, 88, 110, 0, 0, 0],

                                 [0, 510, 12, 132, 154, 176, 0, 0, 0],

                                 [0, 462, 54, 84, 98, 112, 0, 0, 0],

                                 [0, 180, 204, 576, 672, 768, 0, 0, 0],

                                 [0, 0, 0, 0, 0, 0, 0, 0, 0],

                                 [0, 0, 0, 0, 0, 0, 0, 0, 0],

                                 [0, 0, 0, 0, 0, 0, 0, 0, 0]]

Sample Input:
<class 'list'>
A: [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
B: [[85, 77, 30], [2, 9, 34], [22, 14, 96]]

Expected Output:
<class 'numpy.ndarray'>
[[ 0 0 0 85 77 30 170 154 60] [ 0 0 0 2 9 34 4 18 68] [ 0 0 0 22 14 96 44 28 192] [255 231 90 340 308 120 425 385 150] [ 6 27 102 8 36 136 10 45 170] [ 66 42 288 88 56 384 110 70 480] [510 462 180 595 539 210 680 616 240] [ 12 54 204 14 63 238 16 72 272] [132 84 576 154 98 672 176 112 768]]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Consequuntur esse eius ex, odio illo facilis asperiores ex. Ullam dolore accusamus odit doloremque molestias, aperiam odio assumenda deleniti iste accusamus obcaecati dolor sit quam eos, minima impedit placeat nemo delectus?

Nam saepe at porro voluptate, cumque id exercitationem eius perspiciatis delectus sint, blanditiis doloribus sequi, animi atque repellat dolorum eaque. Perferendis pariatur unde cupiditate sunt aliquid?

Maxime explicabo dolor odit sed facere totam ipsam consequuntur, voluptatum tenetur in corporis consequuntur optio maiores repellendus ab reiciendis, quos recusandae ipsa a reprehenderit voluptatum necessitatibus expedita placeat iste, laborum accusamus fugiat sed, soluta facere debitis corporis in praesentium ducimus.

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)