Skip to content
RSS feed tkhwang on GitHub tkhwang on Twitter

Patterns problems in javascript

πŸ€ 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, we count the number of lines/rows and loop for them.
    • Next, for the inner loop, we focus on the 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.
  • 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

πŸ“š Reference