![]() |
VOOZH | about |
We have to print a pattern where in middle column contains only 1, right side columns contain constant digit which is greater than 1 and left side columns contains constant digit which is greater than 1. Every row should look like a Palindrome.
Examples :
Input : 3 Output : 1 2 1 2 1 Input : 5 Output : 1 2 1 2 3 2 1 2 3 2 1 2 1
Below is the implementation to print the following pattern :
Output :
1 212 32123 212 1
Time Complexity: O(n2), where n represents the given input.
Auxiliary Space: O(1), no extra space is required, so it is a constant.