Difficulty: Easy
Topics: Pattern Printing
Hint: Print a right-angle triangle pattern of stars (*
). Each row should contain an increasing number of stars, starting from 1 star in the first row.
Example 1:
Input: n = 4
Output:
*
**
***
****
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a square pattern of stars (*
). Each row and column should have the same number of stars.
Example 1:
Input: n = 5
Output:
*****
*****
*****
*****
*****
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a pyramid pattern with stars (*
). The pyramid should have a single peak and each row should have an increasing number of stars, centered horizontally.
Example 1:
Input: n = 3
Output:
*
***
*****
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a diamond pattern with stars (*
). The pattern should include a single peak in the middle with symmetric rows above and below it.
Example 1:
Input: n = 3
Output:
*
***
*****
***
*
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a hollow square pattern with stars (*
). The border of the square should be filled with stars while the inner part should be empty.
Example 1:
Input: n = 5
Output:
*****
* *
* *
* *
*****
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a right-angle triangle pattern with numbers. Each row should contain an increasing sequence of numbers starting from 1.
Example 1:
Input: n = 4
Output:
1
12
123
1234
Difficulty: Easy
Topics: Pattern Printing
Hint: Print an inverted triangle pattern with stars (*
). Each row should contain decreasing numbers of stars from the top row.
Example 1:
Input: n = 5
Output:
*****
****
***
**
*
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a diamond pattern with numbers. The pattern should have a peak in the middle with symmetric rows above and below it.
Example 1:
Input: n = 3
Output:
1
121
12321
121
1
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a right-angle triangle pattern with increasing numbers. Each row should contain a continuous sequence of increasing numbers.
Example 1:
Input: n = 4
Output:
1
23
456
78910
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a pyramid pattern with increasing numbers. Each row should have an increasing sequence of numbers, centered horizontally.
Example 1:
Input: n = 3
Output:
1
232
34543
Difficulty: Medium
Topics: Matrix Pattern
Hint: Print a matrix where elements alternate between 0
and 1
. The pattern should alternate both row-wise and column-wise.
Example 1:
Input: n = 4
Output:
0101
1010
0101
1010
Difficulty: Medium
Topics: Matrix Pattern
Hint: Print Pascal’s Triangle up to N
rows. Each row should be constructed based on the sum of the elements directly above it in the previous row.
Example 1:
Input: n = 4
Output:
1
1 1
1 2 1
1 3 3 1
Difficulty: Medium
Topics: Matrix Pattern
Hint: Print a matrix of consecutive numbers starting from 1, filling rows sequentially.
Example 1:
Input: n = 3
Output:
1 2 3
4 5 6
7 8 9
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern where each row has an increasing width of stars.
Example 1:
Input: n = 3
Output:
*
***
*****
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a right-angle triangle pattern using characters. Each row should contain the same character repeated according to the row number.
Example 1:
Input: n = 3
Output:
A
BB
CCC
Difficulty: Medium
Topics: Matrix Pattern
Hint: Print a checkerboard pattern with two different characters alternating.
Example 1:
Input: n = 4
Output:
XOXOXO
OXOXOX
XOXOXO
OXOXOX
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pyramid pattern where each row increases in the number of stars.
Example 1:
Input: n = 3
Output:
*
***
*****
Difficulty: Medium
Topics: Matrix Pattern
Hint: Print a border pattern using numbers. The border should be filled with numbers, and the inner part should be empty.
Example 1:
Input: n = 4
Output:
1234
1 1
1 1
1234
Difficulty: Medium
Topics: Pattern Printing
Hint: Print an inverted pyramid pattern using characters. Each row should have decreasing characters from the top row.
Example 1:
Input: n = 3
Output:
CCC
BB
A
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a cross pattern using stars. The cross should be centered within a matrix.
Example 1:
Input: n = 5
Output:
***
*
*
*
***
Difficulty: Hard
Topics: Matrix Pattern
Hint: Print a matrix filled with numbers in a spiral pattern. The numbers should start from 1 and increment as you move around the spiral.
Example 1:
Input: n = 3
Output:
1 2 3
8 9 4
7 6 5
Difficulty: Hard
Topics: Pattern Printing
Hint: Print a diamond pattern where each line has increasing width of stars.
Example 1:
Input: n = 3
Output:
*
***
*****
***
*
Difficulty: Hard
Topics: Pattern Printing
Hint: Print a diamond pattern where numbers increase. Each row should show a symmetrical pattern with numbers increasing towards the center.
Example 1:
Input: n = 3
Output:
1
121
12321
121
1
Difficulty: Hard
Topics: Pattern Printing
Hint: Print a pattern where stars increase to a midpoint and then decrease.
Example 1:
Input: n = 3
Output:
*
***
*****
***
*
Difficulty: Hard
Topics: Matrix Pattern
Hint: Print a matrix with a zigzag pattern of numbers. The numbers should alternate direction row-wise.
Example 1:
Input: n = 3
Output:
1 2 3 4
8 7 6 5
9 10 11 12
Difficulty: Hard
Topics: Pattern Printing
Hint: Print a pattern where rows alternate between two characters.
Example 1:
Input: n = 4
Output:
ABAB
BABA
ABAB
BABA
Difficulty: Hard
Topics: Pattern Printing
Hint: Print a pyramid pattern using increasing characters, where each row increases in width and character range.
Example 1:
Input: n = 3
Output:
A
BCD
EFGHI
Difficulty: Hard
Topics: Pattern Printing
Hint: Print a pattern with diagonal lines using characters. Each diagonal line should be aligned properly.
Example 1:
Input: n = 4
Output:
A
B B
C C
D D
Difficulty: Hard
Topics: Matrix Pattern
Hint: Print a matrix where elements follow a diamond pattern with numbers.
Example 1:
Input: n = 3
Output:
1
121
12321
121
1
Difficulty: Hard
Topics: Pattern Printing
Hint: Print a cross pattern using stars with intersecting diagonals.
Example 1:
Input: n = 5
Output:
* * * * *
* * * *
* * *
* *
*
* *
* * *
* * * *
* * * * *
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a triangular matrix where each row contains increasing numbers. Each subsequent row should start from the next number.
Example 1:
Input: n = 3
Output:
1
2 3
4 5 6
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern with stars that increase to a midpoint and then decrease. The stars should be centered horizontally.
Example 1:
Input: n = 3
Output:
*
***
*****
***
*
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern with nested squares using stars. The outermost square should be filled with stars, and each subsequent square should be smaller and centered inside the previous one.
Example 1:
Input: n = 5
Output:
*****
* *
* *
* *
*****
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern where each column contains increasing characters from A
.
Example 1:
Input: n = 3
Output:
A
B C
D E F
Difficulty: Hard
Topics: Matrix Pattern
Hint: Print a matrix with numbers arranged in diagonal spirals. The numbers should fill the matrix in a diagonal spiral fashion.
Example 1:
Input: n = 3
Output:
1 2 3
4 5 6
7 8 9
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a checkerboard pattern where the size of each square increases as you move along the matrix.
Example 1:
Input: n = 3
Output:
XOX
OXO
XOX
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a cross pattern where the size of the cross increases with each row. The pattern should be centered.
Example 1:
Input: n = 3
Output:
*
***
*****
***
*
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern with alternating triangles of stars. The triangles should alternate direction.
Example 1:
Input: n = 3
Output:
*
***
*****
***
*
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a matrix where numbers form a diamond pattern. The numbers should increase and decrease symmetrically around the center.
Example 1:
Input: n = 3
Output:
1
121
12321
121
1
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern where the width of stars increases, and the stars are centered horizontally.
Example 1:
Input: n = 3
Output:
*
***
*****
Difficulty: Hard
Topics: Matrix Pattern
Hint: Print a matrix with both spiral and zigzag patterns. The matrix should first fill in a spiral pattern and then in a zigzag fashion.
Example 1:
Input: n = 3
Output:
1 2 3
6 5 4
7 8 9
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a matrix where characters alternate in each cell to form a pattern.
Example 1:
Input: n = 3
Output:
ABAB
BABA
ABAB
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern with nested triangles of stars. Each triangle should be centered and decrease in size.
Example 1:
Input: n = 3
Output:
*
***
*****
***
*
Difficulty: Easy
Topics: Matrix Pattern
Hint: Print a matrix where each row and column contains increasing numbers.
Example 1:
Input: n = 3
Output:
1 2 3
4 5 6
7 8 9
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern where each row contains an increasing sequence of characters.
Example 1:
Input: n = 3
Output:
A
BC
DEF
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern with a diamond shape of stars, with numbers inside the diamond.
Example 1:
Input: n = 3
Output:
1
121
12321
121
1
Difficulty: Hard
Topics: Matrix Pattern
Hint: Print a matrix where the center forms a cross pattern with numbers.
Example 1:
Input: n = 5
Output:
12321
01210
01210
01210
12321
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a pattern with concentric squares using stars. The outer square should be larger and each subsequent square should be centered inside.
Example 1:
Input: n = 5
Output:
*****
* *
* *
* *
*****
Difficulty: Easy
Topics: Pattern Printing
Hint: Print a pattern with alternating rows and columns of numbers, where each row and column increases sequentially.
Example 1:
Input: n = 3
Output:
123
456
789
Difficulty: Medium
Topics: Pattern Printing
Hint: Print a matrix where stars form a zigzag pattern, alternating rows in their positioning.
Example 1:
Input: n = 3
Output:
* * *
* *
* * *