• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
November 28, 2022 |4.8K Views
Java program to print square star pattern with diagonal
  Share  5 Likes
Description
Discussion

In this video, we will be writing a Java program to print a square star diagonal pattern. 

To develop a square star pattern lets summarize the main blocks of logic: 
1) First and last rows and columns needs to be printed first. 
2) For the first diagonal we need to set when rows == column. 
3) For the second diagonal we need to set rows + cols == n(Dimensions of the square). 

To implement this we need to use nested for loops hence the time complexity of this algorithm is O(n^2) and the space complexity of the algorithm is O(1) as no extra space has been used. 

Print square star pattern in Java:
https://www.geeksforgeeks.org/java-program-to-print-square-star-pattern/

Read More