11

Java Program to Print Hollow Diamond Star Pattern

 3 years ago
source link: https://www.geeksforgeeks.org/videos/java-program-to-print-hollow-diamond-star-pattern/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Java Program to Print Hollow Diamond Star Pattern

Java Program to Print Hollow Diamond Star Pattern
  • 12/06/2022

In this video, we will see a JAVA program to Print Hollow & Diamond Star Pattern. When it comes to pattern printing we do opt for standard ways of printing them via loops only.

Here we print a hollow diamond star pattern using “for loop”.

Basic method to print Hollow Diamond Star Pattern: To print the box shape we need to print ‘-‘ for i==1 (first row) & i==n (last row) and ‘|’ for j==1 (first column) and j==n (last column).

Here time and space complexity are as follows: 1) Time Complexity: O(n*n) since we are traversing rows and columns of a grid for printing spaces ‘ ‘ and star ‘*’. 2) Auxiliary Space: O(1), No extra Space used.

Java program to print diamond shape star pattern: https://www.geeksforgeeks.org/program-print-hollow-pyramid-diamond-pattern/


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK