Problem of the day
N = 2
M = 2
B = [ [1, 2], [3, 4] ]
R = 1
C = 4
Both arrangements (box and shelf) are shown below:
Return [ [1, 2, 3, 4] ] as our final answer.
The first line contains an integer 'T', denoting the number of test cases.
Then the test cases follow:
The first line of each test case contains two space-separated integers, 'N' and 'M', denoting the number of rows and columns in the box 'B', respectively.
The following 'N' lines contain 'M' integers, denoting the toys' IDs in box 'B'.
Next line contains two space-separated integers, 'R' and 'C', denoting the number of rows and columns in the shelf 'S', respectively.
For each test case, print a matrix of size 'R*C' denoting the toy's arrangement on the shelf 'S'.
Print the output of each test case in a new line.
You are not required to print the expected output. It has already been taken care of. Just implement the function.
1 <= 'T' <= 10
1 <= 'N', 'M', 'R', 'C' <= 100
-10^3 <= 'B[i][j]' <= 10^3
Time Limit: 1 sec
2
2 4
5 0 3 2
1 5 5 3
4 2
3 3
3 2 6
1 2 3
5 1 9
2 4
5 0
3 2
1 5
5 3
3 2 6
1 2 3
5 1 9
For test case 1:
Given matrix 'B' is [ [5, 0, 3, 2], [1, 5, 5, 3] ]. Converting it to a matrix of size 4*2 will look as 'S' = [ [5, 0], [3, 2], [1, 5], [5, 3] ].
For test case 2:
After arrangement on the shelf, one toy (with toy ID = 9) remains in the box. Shown in the below image.
Hence return the given matrix 'B' as the final answer.
2
3 3
4 -1 3
2 2 -2
1 3 1
3 5
3 4
5 2 4 7
6 3 4 2
3 7 5 6
2 6
4 -1 3
2 2 -2
1 3 1
5 2 4 7 6 3
4 2 3 7 5 6