How to approach pattern problems?

Hi
I am having trouble in solving pattern problems. Can you explain how to approach them.

@sahilsaini137 hey sahil
In Pattern Question, there is a common method which we teach in course viz, taking nsp, nst, csp, cst and row variables.

Pattern Hack: Always first Try to first print pattern by ignoring the value to be printed then accommodate your value in that pattern. For e.g.,

     5                   5 
     5 4               4 5 
     5 4 3           3 4 5 
     5 4 3 2       2 3 4 5 
     5 4 3 2 1   1 2 3 4 5 
     5 4 3 2 1 0 1 2 3 4 5 
     5 4 3 2 1   1 2 3 4 5 
     5 4 3 2       2 3 4 5 
     5 4 3           3 4 5 
     5 4               4 5 
     5                   5 

View it as:-

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

Short Info about the variables:-

  1. nsp (number of spaces)-> Number of spaces in very First Line of the pattern.
  2. nst (number of stars)-> Number of stars in very first line of the pattern.
  3. csp (counter of spaces)-> counter of spaces that will print the required number of spaces and will be initialized with 1 and incremented upto nsp.
  4. cst (counter of stars)-> counter of spaces that will print the required number of stars and will be initialized with 1 and incremented upto nst.
  5. rows -> It will be initialized with 1 and will go upto the total number of rows
    In the given pattern,

First build an intuition that u need to work for first row and at the end of the loop need to do work for the next row.
For each row first you need to print your pattern in decreasing order then spaces and then the same pattern but in increasing order.
To build the whole pattern just repeat this work according to total number of rows. With this approach, things seems to work out easily.