Unity is Strength
Infinity Stones are so powerful, and no normal human being can hold the stone and stay alive. After the avengers has set the path right by destroying Thanos. Thanos had sent a time remnant. Time remnants, also known as timeline remnants or temporal duplicates. He sent back in time and destroyed Tony Start, the Iron Man. So without him, who will snap the finger and kill Thanos?
But time are so many possibilities. Now normal people have joined hands to fight against Thanos. But no one can hold the stone alone. So Dr. Banner has designed a machine such that, the machine can be held by many people together. The people are categorized by their power, from 1 to N. They have to stand in form of a square. Dr. Banner has found out that people with powers of 1 to N are required, and a person with power 1 will be standing in the center and people with power 2 will form a smallest possible square around him. This will be continued until people with power N form a square. Now they all will will hold the device together and destroy Thanos. Dr. Banner, is busy making the machine ready. Can you help him, by making people stand in the required order and protect the world!
Input Format : One single integer N
Input Constraints : 1<=N<=100
Output Format : The pattern thus required
Sample Input :
4
Sample Output :
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
C-Sort
Given a 2D array , sort each column in ascending order.
Input Format : The first line consists of an integer N, which denotes the row and column size Next N lines follow the matrix
Input Constraints : 1 <= N <= 500 1 <= Mat[i][j] <= 10^9
Output Format : N lines of matrix output
Sample Input :
3 1 3 2 8 7 9 5 4 6
Sample Output :
1 3 2 5 4 6 8 7 9
Post a Comment