Pattern-Based Programming Questions (All 35 Questions - Interview
Style)
🔷 Square, Rectangle, and Triangle Patterns (1–15)
1. Solid Square Pattern
Problem: Print a solid square of stars of size n.
Input: n = 4
Output:
* * * *
* * * *
* * * *
* * * *
2. Solid Rectangle Pattern
Problem: Print a solid rectangle of m rows and n columns.
Input: m = 3, n = 5
Output:
* * * * *
* * * * *
* * * * *
3. Right-Angled Triangle (Left-Aligned)
Problem: Print a left-aligned right-angled triangle.
Input: n = 5
Output:
*
* *
* * *
* * * *
* * * * *
4. Right-Angled Triangle (Right-Aligned)
Input: n = 5
Output:
*
* *
* * *
* * * *
* * * * *
5. Inverted Triangle (Left-Aligned)
Input: n = 5
Output:
* * * * *
* * * *
* * *
* *
*
6. Inverted Triangle (Right-Aligned)
Input: n = 5
Output:
* * * * *
* * * *
* * *
* *
*
7. Centered Pyramid Pattern
Input: n = 4
Output:
*
* * *
* * * * *
* * * * * * *
8. Diamond Pattern
Input: n = 3
Output:
*
* * *
* * * * *
* * *
*
9. Butterfly Pattern
Input: n = 4
Output:
* *
* * * *
* * * * *
* * * *
* *
10. Left-Aligned Half Diamond
Input: n = 4
Output:
*
* *
* * *
* * * *
* * *
* *
*
11. Right-Aligned Half Diamond
Input: n = 4
Output:
*
* *
* * *
* * * *
* * *
* *
*
12. Sandglass Pattern
Input: n = 4
Output:
* * * *
* * *
* *
*
* *
* * *
* * * *
13. Increasing Width Triangle
Input: n = 5
Output:
*
* *
* * *
* * * *
* * * * *
14. Decreasing Width Triangle
Input: n = 5
Output:
* * * * *
* * * *
* * *
* *
*
15. Right-Aligned Hill Pattern
Input: n = 4
Output:
*
* *
* * *
* * * *
🔲 Hollow Patterns (16–25)
16. Hollow Square Pattern
Problem: Print a hollow square of stars of size n.
Input: n = 4
Output:
* * * *
* *
* *
* * * *
17. Hollow Rectangle Pattern
Problem: Print a hollow rectangle of m rows and n columns.
Input: m = 4, n = 5
Output:
* * * * *
* *
* *
* * * * *
18. Hollow Right-Angled Triangle (Left-Aligned)
Input: n = 5
Output:
*
* *
* *
* *
* * * * *
19. Hollow Right-Angled Triangle (Right-Aligned)
Input: n = 5
Output:
*
* *
* *
* *
* * * * *
20. Hollow Inverted Triangle (Left-Aligned)
Input: n = 5
Output:
* * * * *
* *
* *
* *
*
21. Hollow Inverted Triangle (Right-Aligned)
Input: n = 5
Output:
* * * * *
* *
* *
* *
*
22. Hollow Pyramid Pattern
Input: n = 4
Output:
*
* *
* *
* * * * * * *
23. Hollow Diamond Pattern
Input: n = 3
Output:
*
* *
* *
* *
*
24. Hollow Butterfly Pattern
Input: n = 4
Output:
* *
* * * *
* * *
* *
* * *
* * * *
* *
25. Hollow Hourglass Pattern
Input: n = 5
Output:
* * * * *
* *
* *
*
* *
* *
* * * * *
🔢 Number-Based Patterns (26–35)
26. Increasing Number Triangle
Problem: Print numbers from 1 to n in triangle form.
Input: n = 5
Output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
27. Repeating Row Number Triangle
Input: n = 5
Output:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
28. Continuous Number Triangle
Input: n = 4
Output:
1
2 3
4 5 6
7 8 9 10
29. Reverse Row Number Triangle
Input: n = 5
Output:
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
30. Inverted Number Triangle
Input: n = 5
Output:
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
31. Right-Aligned Number Triangle
Input: n = 5
Output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
32. Pyramid Number Pattern
Input: n = 4
Output:
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
33. Even Number Triangle
Input: n = 5
Output:
2
2 4
2 4 6
2 4 6 8
2 4 6 8 10
34. Odd Number Triangle
Input: n = 5
Output:
1
1 3
1 3 5
1 3 5 7
1 3 5 7 9
35. Pascal’s Triangle
Input: n = 5
Output:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
✅ All 35 pattern questions are now fully formatted in an interview-style
layout with problem statements, inputs, and expected outputs.
Would you like to:
🐍 Add Python code for each?
📥 Export as a PDF?