π General guideline
There are 4 general rules for solving a pattern-based question :
- We always use nested loops for printing the patterns.
- For the
outer loop
, wecount the number of lines/rows
and loop for them.
- Next, for the
inner loop
, we focus onthe number of columns
and somehow connect them to the rows by forming a logic such that for each row we get the required number of columns to be printed.
- For the
- We print the numbers inside the
inner loop
. Observe symmetry
in the pattern or check if a pattern is a combination of two or more similar patterns or not.
ποΈ Typical problems
- Typical problems are solved in the following links.