Build a Hollow Diamond Pattern
00:00
Given an integer n, print a hollow diamond pattern of height 2n - 1. A hollow diamond contains stars only on the borders of the diamond shape.
For n=3, the pattern looks like this:
*
* *
* *
* *
*
Constraints:
- 1 <= n <= 20
- The output should contain exactly
2n - 1lines.
Examples
Input → 1
Output → *
Explanation:
A single row with one star.
Input → 2
Output → *
* *
*
Explanation:
A hollow diamond of size 2.
Input → 3
Output → *
* *
* *
* *
*
Explanation:
A hollow diamond of size 3.