Inverted triangle of stars
Easy Accuracy: 53.82% Submissions: 606 Points: 2

Given an integer N, print an inverted isosceles triangle of stars such that the height of the triangle is N.

 

Example 1:

Input:
N = 4
Output:
*******
 *****
  ***
   *

Example 2:

Input:
N = 3
Output:
*****
 ***
  *

 

Your Task:
You don't need to read input or print anything. Your task is to complete the function invIsoTriangle() which takes an Integer N as input and returns a vector of strings where each line represents lines of the pattern. For example, if N=2, the vector v = {"***", " * "}.

 

Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)

 

Constraints:
1 <= N <= 100

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Inverted triangle of stars

Output Window