The pattern for ‘N’ = 7 will look like this:
*
**
***
****
***
**
*
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 one integer, ‘N’, denoting the number of rows.
For each test case, print 'N' strings denoting the pattern.
The output of each test case will be printed on a separate line.
You do not need to input or print anything, as it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 99
Time Limit: 1 sec
Here we can Initialising precompute a string of size (n + 1) / 2. For each row using the substring function, we can extract the number of stars needed and put them in an array of strings. We can run a loop where till the central row, we will increase the number of stars. We can keep a counter variable that will be increasing till the central row and decrease henceforth. Using this variable, we can calculate how many stars are required to be taken from the precomputed string.
Number of Digits
Matrix Boundary Traversal
Star Triangle
Print Fibonacci Series
Print Fibonacci Series
Print Fibonacci Series
Print Fibonacci Series
Print Fibonacci Series
Print Fibonacci Series
Inverted Left Half Pyramid