Update appNew update is available. Click here to update.

Magical Pattern

Contributed by
Ashwani
Last Updated: 23 Feb, 2023
Easy
yellow-spark
0/40
Avg time to solve 20 mins
Success Rate 80 %
Share
6 upvotes

Problem Statement

You have been given an integer 'N'. Your task is to print the Magical Pattern(see examples) for the given 'N'.

Example :

For 'N' : 4
Pattern :
4 3 2 1 2 3 4                                                                   
3 3 2 1 2 3 3                                                                   
2 2 2 1 2 2 2                                                                   
1 1 1 1 1 1 1                                                                   
2 2 2 1 2 2 2                                                                   
3 3 2 1 2 3 3                                                                   
4 3 2 1 2 3 4
Detailed explanation ( Input/output format, Notes, Images )
Constraints :
1 <= T <= 10
1 <= N <= 10^2

Time Limit : 1 sec
Sample Input 1 :
1
3
Sample Output 1 :
3 2 1 2 3 
2 2 1 2 2  
1 1 1 1 1 
2 2 1 2 2 
3 2 1 2 3 
Sample Input 2 :
1
5
Sample Output 2 :
5 4 3 2 1 2 3 4 5 
4 4 3 2 1 2 3 4 4 
3 3 3 2 1 2 3 3 3 
2 2 2 2 1 2 2 2 2 
1 1 1 1 1 1 1 1 1 
2 2 2 2 1 2 2 2 2 
3 3 3 2 1 2 3 3 3 
4 4 3 2 1 2 3 4 4 
5 4 3 2 1 2 3 4 5 
Reset Code
Full screen
Auto
copy-code
Console