To print the character, we have to take an input that will denote the numbers the lines or size the pattern needs to be. We have to write conditions that make up the boundary pattern with diagonal and anti-diagonal.
Taking an input from the user, we print ‘*’ inside the nested loop whenever the if condition is raised True depending upon the following different criteria.
1. Current row is first or nth
2. Current column is first or nth
3. Diagonal where i == j
4. Anti-diagonal where j == n-i-1
Space Complexity: O(1)
Time Complexity: O(n^2)