Pattern 20

Beginner Problems Patterns Medium
  • This problem demonstrates the concept of loops and pattern recognition/matching which is a fundamental aspect in many software applications
  • In the real-world, pattern generation problems like this are commonly used in computer graphics and game development to generate textures, shapes, or terrain
  • It is also used in tools like regular expression engines which are widely used in text parsing, syntax highlighting, data validation, and search functionalities which are core to numerous software applications
  • Interesting fact: Algorithms to generate complex patterns are also pivotal in certain aspects of cryptography and data security

Given an integer n. You need to recreate the pattern given below for any value of N. Let's say for N = 5, the pattern should look like as below:


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


Print the pattern in the function given to you.

Constraints

  • 1 <= n <= 20

Company Tags

TCS Cognizant Accenture Infosys Capgemini Wipro IBM HCL Tech Mahindra MindTree