Asked inUBS,ENO
Print the Pattern

Ninja is given a pattern. Now he is asked to print the same pattern for any given ‘N’ number of rows.

Note:

There is only one space between the values of each column in a row.

For example, Pattern for ‘N’ = 5 will be.
1 2 3 4 5 
11 12 13 14 15 
21 22 23 24 25 
16 17 18 19 20 
6 7 8 9 10 

Input Format:

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 a single integer ‘N’ denoting the number of rows for which pattern needs to be printed.

Output Format:

The output of each test case will be 'N' strings denoting the pattern printed for the given ‘N’ number of rows.

The output of each test case will be printed on a separate line.

Constraints:

1 <=T <= 5 
1 <= N <= 100

Where ‘T’ is the total number of test cases and ‘N’ is the given number of rows for which pattern needs to be printed.

Time limit: 1 sec
CodingNinjas
author
2y

printPattern()
{

declare variables i,j,k,sp
initialise space to 4

for (i = 1 to i<=5) do :
{

// For printing the space
for (sp = space to sp >= 1) do :
{
print space
}

// For printing the $
for (j=1 to j<=i) ...read more

CodingNinjas
author
2y
Observation

We can observe that there are ‘N’ numbers of rows (where ‘N’ is the total number of rows to be printed). Each row contains a different value in the first column and its value increments by ...read more

Help your peers!
Add answer anonymously...
UBS ENO Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter