Top 50 Pattern Programming Questions (Fresher to Experienced)

Basic Star Patterns

1. Square Star Pattern

* * * *
* * * *
* * * *
* * * *

2. Right Triangle Star Pattern

*
* *
* * *
* * * *

3. Inverted Right Triangle

* * * *
* * *
* *
*

4. Left Triangle Pattern

      *
* *
* * *
* * * *

5. Pyramid Pattern

      *
* * *
* * * * *
* * * * * * *

6. Inverted Pyramid

* * * * * * *
* * * * *
* * *
*

7. Diamond Pattern

    *
***
*****
***
*

8. Hollow Square Pattern

* * * *
* *
* *
* * * *

9. Hollow Triangle Pattern

10. Hollow Pyramid Pattern


Number Patterns

11. Number Square Pattern

1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4

12. Increasing Number Triangle

1
1 2
1 2 3
1 2 3 4

13. Floyd’s Triangle

1
2 3
4 5 6
7 8 9 10

14. Pascal Triangle

15. Reverse Number Triangle

1 2 3 4
1 2 3
1 2
1

16. Continuous Number Pattern

1
2 3
4 5 6
7 8 9 10

17. Palindrome Number Pattern

1
121
12321
1234321

18. Zig-Zag Number Pattern

19. Snake Number Pattern

20. Spiral Matrix Pattern


Alphabet Patterns

21. Alphabet Square Pattern

A B C D
A B C D
A B C D
A B C D

22. Alphabet Triangle Pattern

A
A B
A B C
A B C D

23. Continuous Alphabet Pattern

A
B C
D E F

24. Reverse Alphabet Pattern

25. Alphabet Pyramid Pattern

26. Palindrome Alphabet Pattern

A
ABA
ABCBA
ABCDCBA

27. Character Diamond Pattern

28. Hollow Alphabet Pyramid

29. Alternate Alphabet Pattern

30. Alphabet Hourglass Pattern


Advanced Star Patterns

31. Butterfly Pattern

*      *
** **
*** ***
********
*** ***
** **
* *

32. Sandglass Pattern

33. Hourglass Star Pattern

34. X Pattern

*     *
* *
* *
* *
* *

35. Plus Pattern

36. Hollow Diamond Pattern

37. Hollow Butterfly Pattern

38. Rhombus Pattern

39. Hollow Rhombus Pattern

40. Double Pyramid Pattern


Matrix & Logic-Based Patterns

41. Spiral Star Pattern

42. Spiral Number Pattern

43. Concentric Square Pattern

Example:

4 4 4 4 4 4 4
4 3 3 3 3 3 4
4 3 2 2 2 3 4
4 3 2 1 2 3 4
4 3 2 2 2 3 4
4 3 3 3 3 3 4
4 4 4 4 4 4 4

44. Binary Pattern

1
0 1
1 0 1
0 1 0 1

45. Checkerboard Pattern

46. Diagonal Matrix Pattern

47. Border Element Pattern

48. Wave Matrix Pattern

49. Spiral Boundary Traversal Pattern

50. Hollow Concentric Pattern


Common Interview Follow-Up Questions

Interviewers also ask:

  • Optimize nested loops
  • Reduce space complexity
  • Print without using extra arrays
  • Convert pattern to recursion
  • Use only one loop
  • Print patterns dynamically for any n
  • Dry run the code manually

Most Important Patterns for Interviews

If you want to prepare quickly, focus on these first:

  1. Pyramid Pattern
  2. Diamond Pattern
  3. Butterfly Pattern
  4. Pascal Triangle
  5. Floyd Triangle
  6. Hollow Square
  7. Spiral Matrix
  8. Concentric Square
  9. Palindrome Pattern
  10. X and Hourglass Patterns

Tips to Solve Any Pattern

  1. Understand rows and columns
  2. Observe spaces carefully
  3. Divide pattern into sections
  4. Use nested loops properly
  5. Dry run for n = 5
  6. Practice symmetry patterns daily

Recommended Practice Order

Beginner

  • Square
  • Triangle
  • Number patterns
  • Alphabet patterns

Intermediate

  • Pyramid
  • Diamond
  • Hollow patterns
  • Butterfly

Advanced

  • Spiral matrix
  • Concentric square
  • Pascal triangle
  • Zig-zag patterns

This was part of Interview Preparation With Bipin — Let’s Crack It!

Comments

Popular posts from this blog

Angular Architecture

Why should I learn Angular?

Solid Principle