Pattern: Triangle of numbers
Ninja is given a pattern. Now he is asked to print the same pattern for any given ‘N’ number of rows.
For example, Pattern for ‘N’ = 4 will be.
1
232
34545
4567654
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.
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
In pattern based programs, two things need to be taken care of : No. of lines and If the pattern is increasing or decreasing per line.
Pseudo Code :
printPattern(n) :
num = 1;
gap = n - 1;
for (j=1 to n ,...read more
CodingNinjas
author
2y
Observation
We can observe that there is an ‘N’ number of rows where ‘N’ is the total number of rows to be printed. And each row exactly contains ‘N’ - ‘row’ number of spaces where ‘row’ denotes the ro...read more
Help your peers!
Add answer anonymously...
Top Info Edge Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Info Edge Software Developer
Stay ahead in your career. Get AmbitionBox app
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