62. Diamond Pattern

Acceptance — 0 accepted 0 submissions

Easy
Nested LoopsPatterns
No companies listed
Combine what you've learned to print a diamond, a pyramid on top of an upside-down pyramid.

For N = 3 the rows have 1, 3, 5, 3 and 1 stars, each centred with spaces on the left. See Example 1 for the exact shape.

Input Format
A single integer N (the number of rows in the top half, including the middle row).

Output Format
Print 2N - 1 lines. Do not print spaces after the stars.

Constraints
• 1 ≤ N ≤ 30

Example 1

Input
3
Output
  *
 ***
*****
 ***
  *

Explanation Pyramid of 3 rows, then 2 rows shrinking back.

Example 2

Input
1
Output
*

Explanation Just one star.

Example 3

Input
2
Output
 *
***
 *

Explanation Three lines: 1, 3 and 1 stars.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
* *** ***** *** *
No results yet
Run your code to test it against the sample cases.
Problem List