


Print the following pattern
Pattern for N = 4
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain an integer ‘N’ that is the total number of rows.
Output Format:
For each test case, print the pattern of N lines.
Output for every test case will be printed in a separate line.
1 <= T <= 100
1 <= N <= 100
2
1
2
*
*
***
2
3
4
*
***
*****
*
***
*****
*******
Can you think of using two loops?
The basic idea of this approach is to print the pattern row-wise. The pattern consists of ’N’ rows. Each row contains 2 * ‘N’ - 1 star. In addition to these stars, there are leading spaces. Each row contains ‘N’ - ‘Row’ spaces (where ‘ROW’ is the current row number).
Here is the algorithm:
O(N^2), where N is the number of rows.
Because we are using two loops, the outer loop runs for the number of rows given to us, and the inner loop prints the value for every column. Hence the time complexity is O(N^2).
O(1),
Because we are not using any extra space for finding our answer.