4 4 4 4 4 4 4
4 3 3 3 3 3 4
4 3 2 2 2 3 4
4 3 2 1 2 3 4
4 3 2 2 2 3 4
4 3 3 3 3 3 4
4 4 4 4 4 4 4
The first line contains an integer 'T' which denotes the number of test cases or queries to be run.
The first line of each test case contains one integer ‘N’ for the number of rectangles.
For each case, return a 2-d list/array of integers denoting the pattern.
The output of each test case will be printed in a separate line.
You do not need to input or print anything, and it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 100
Time limit: 1 sec.
As we need to move rectangles for each number from N to 1, we start with a loop where N is decreasing after iteration of the loop. Inside the loop, we basically only need to choose the location of the border elements. So we can run a nested loop as we travel in the case of a 2D array and whenever we stand at the border indexes, we need to put the number in that index.
Milk flow
Draw The Diamond
Draw The Diamond
Pattern Printing
Number of Digits
Matrix Boundary Traversal