Episode 7 — DSA with JavaScript / 7.2 — Loops Nested Loops Pattern Programming

7.2.b — Nested Loops & Pattern Programming

<< 7.2 Overview


Understanding nested loops

A nested loop is a loop inside another loop. For each iteration of the outer loop, the inner loop runs completely.

Outer loop: i = 1 to 3
  Inner loop: j = 1 to 4
  → Executes 3 × 4 = 12 times total
i=1  j=1,2,3,4
i=2  j=1,2,3,4
i=3  j=1,2,3,4
     ─────────
     12 iterations

Basic example: multiplication table

for (let i = 1; i <= 5; i++) {
    let row = "";
    for (let j = 1; j <= 10; j++) {
        row += `${(i * j).toString().padStart(4)}`;
    }
    console.log(row);
}

Output:

   1   2   3   4   5   6   7   8   9  10
   2   4   6   8  10  12  14  16  18  20
   3   6   9  12  15  18  21  24  27  30
   4   8  12  16  20  24  28  32  36  40
   5  10  15  20  25  30  35  40  45  50
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    for (int i = 1; i <= 5; i++) {
        for (int j = 1; j <= 10; j++) {
            cout << setw(4) << i * j;
        }
        cout << endl;
    }
    return 0;
}

Pattern programming

Pattern programming is a classic exercise that builds understanding of:

  • Loop control flow
  • Relationship between row index and column count
  • Building complex output from simple rules

Pattern 1: Right-angled triangle (stars)

*
**
***
****
*****
function rightTriangle(n) {
    for (let i = 1; i <= n; i++) {
        console.log("*".repeat(i));
    }
}
rightTriangle(5);
void rightTriangle(int n) {
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < i; j++) cout << "*";
        cout << endl;
    }
}

Logic: Row i has i stars.


Pattern 2: Inverted right triangle

*****
****
***
**
*
function invertedTriangle(n) {
    for (let i = n; i >= 1; i--) {
        console.log("*".repeat(i));
    }
}
void invertedTriangle(int n) {
    for (int i = n; i >= 1; i--) {
        for (int j = 0; j < i; j++) cout << "*";
        cout << endl;
    }
}

Logic: Row i (counting down from n) has i stars.


Pattern 3: Number triangle

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
function numberTriangle(n) {
    for (let i = 1; i <= n; i++) {
        let row = "";
        for (let j = 1; j <= i; j++) {
            row += j + " ";
        }
        console.log(row.trim());
    }
}

Pattern 4: Pyramid (centered)

    *
   ***
  *****
 *******
*********
function pyramid(n) {
    for (let i = 0; i < n; i++) {
        const spaces = " ".repeat(n - 1 - i);
        const stars = "*".repeat(2 * i + 1);
        console.log(spaces + stars);
    }
}
pyramid(5);
void pyramid(int n) {
    for (int i = 0; i < n; i++) {
        for (int s = 0; s < n - 1 - i; s++) cout << " ";
        for (int j = 0; j < 2 * i + 1; j++) cout << "*";
        cout << endl;
    }
}

Logic:

  • Row i (0-indexed): (n-1-i) spaces, then (2i+1) stars
Row 0: 4 spaces, 1 star   → "    *"
Row 1: 3 spaces, 3 stars  → "   ***"
Row 2: 2 spaces, 5 stars  → "  *****"
Row 3: 1 space,  7 stars  → " *******"
Row 4: 0 spaces, 9 stars  → "*********"

Pattern 5: Inverted pyramid

*********
 *******
  *****
   ***
    *
function invertedPyramid(n) {
    for (let i = n - 1; i >= 0; i--) {
        const spaces = " ".repeat(n - 1 - i);
        const stars = "*".repeat(2 * i + 1);
        console.log(spaces + stars);
    }
}

Pattern 6: Diamond

    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *
function diamond(n) {
    // upper half (including middle)
    for (let i = 0; i < n; i++) {
        const spaces = " ".repeat(n - 1 - i);
        const stars = "*".repeat(2 * i + 1);
        console.log(spaces + stars);
    }
    // lower half
    for (let i = n - 2; i >= 0; i--) {
        const spaces = " ".repeat(n - 1 - i);
        const stars = "*".repeat(2 * i + 1);
        console.log(spaces + stars);
    }
}
diamond(5);
void diamond(int n) {
    for (int i = 0; i < n; i++) {
        for (int s = 0; s < n-1-i; s++) cout << " ";
        for (int j = 0; j < 2*i+1; j++) cout << "*";
        cout << endl;
    }
    for (int i = n-2; i >= 0; i--) {
        for (int s = 0; s < n-1-i; s++) cout << " ";
        for (int j = 0; j < 2*i+1; j++) cout << "*";
        cout << endl;
    }
}

Pattern 7: Hollow rectangle

*****
*   *
*   *
*****
function hollowRect(rows, cols) {
    for (let i = 0; i < rows; i++) {
        let row = "";
        for (let j = 0; j < cols; j++) {
            if (i === 0 || i === rows - 1 || j === 0 || j === cols - 1) {
                row += "*";
            } else {
                row += " ";
            }
        }
        console.log(row);
    }
}
hollowRect(4, 5);

Pattern 8: Pascal's triangle

    1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1
function pascalTriangle(n) {
    for (let i = 0; i < n; i++) {
        let row = [];
        let val = 1;
        const spaces = " ".repeat(n - 1 - i);
        for (let j = 0; j <= i; j++) {
            row.push(val);
            val = val * (i - j) / (j + 1);
        }
        console.log(spaces + row.join(" "));
    }
}
pascalTriangle(5);
#include <iostream>
#include <vector>
using namespace std;

void pascalTriangle(int n) {
    for (int i = 0; i < n; i++) {
        for (int s = 0; s < n-1-i; s++) cout << " ";
        int val = 1;
        for (int j = 0; j <= i; j++) {
            cout << val << " ";
            val = val * (i - j) / (j + 1);
        }
        cout << endl;
    }
}

Pattern 9: Floyd's triangle

1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
function floydsTriangle(n) {
    let num = 1;
    for (let i = 1; i <= n; i++) {
        let row = "";
        for (let j = 1; j <= i; j++) {
            row += num + " ";
            num++;
        }
        console.log(row.trim());
    }
}

Pattern 10: Butterfly

*        *
**      **
***    ***
****  ****
**********
****  ****
***    ***
**      **
*        *
function butterfly(n) {
    // Upper half
    for (let i = 1; i <= n; i++) {
        const stars = "*".repeat(i);
        const spaces = " ".repeat(2 * (n - i));
        console.log(stars + spaces + stars);
    }
    // Lower half
    for (let i = n - 1; i >= 1; i--) {
        const stars = "*".repeat(i);
        const spaces = " ".repeat(2 * (n - i));
        console.log(stars + spaces + stars);
    }
}
butterfly(5);

Pattern 11: Sandglass

*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********
function sandglass(n) {
    for (let i = n - 1; i >= 0; i--) {
        const spaces = " ".repeat(n - 1 - i);
        const stars = "*".repeat(2 * i + 1);
        console.log(spaces + stars);
    }
    for (let i = 1; i < n; i++) {
        const spaces = " ".repeat(n - 1 - i);
        const stars = "*".repeat(2 * i + 1);
        console.log(spaces + stars);
    }
}
sandglass(5);

Pattern 12: Alphabet triangle

A
A B
A B C
A B C D
A B C D E
function alphabetTriangle(n) {
    for (let i = 0; i < n; i++) {
        let row = "";
        for (let j = 0; j <= i; j++) {
            row += String.fromCharCode(65 + j) + " ";
        }
        console.log(row.trim());
    }
}

Time complexity of nested loops

Single loop:     O(n)
Two nested:      O(n²)
Three nested:    O(n³)
Loop to sqrt(n): O(√n)

Example:
for (let i = 0; i < n; i++) {          // O(n)
    for (let j = 0; j < n; j++) {      //   × O(n)
        // operation                    // = O(n²)
    }
}

Scenario bank (nested loops & patterns)

7.2b-001 — Right triangle with numbers instead of stars (variation 1)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-002 — Inverted pyramid with descending numbers (variation 2)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-003 — Hollow diamond pattern (variation 3)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-004 — Checkerboard pattern (alternating * and spaces) (variation 4)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-005 — Spiral number pattern (variation 5)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-006 — Zigzag pattern (variation 6)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-007 — Arrow pattern pointing right (variation 7)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-008 — X pattern (two diagonals) (variation 8)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-009 — Rhombus pattern (variation 9)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-010 — Heart shape pattern (variation 10)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-011 — Number pyramid with centered alignment (variation 11)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-012 — Hollow triangle pattern (variation 12)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-013 — Reverse Floyd's triangle (variation 13)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-014 — Binary triangle (alternating 0 and 1) (variation 14)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-015 — Cross (+) pattern (variation 15)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-016 — Crown pattern (variation 16)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-017 — Wave pattern (variation 17)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-018 — Staircase pattern (variation 18)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-019 — Hourglass with numbers (variation 19)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-020 — Matrix spiral order print (variation 20)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-021 — Right triangle with numbers instead of stars (variation 21)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-022 — Inverted pyramid with descending numbers (variation 22)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-023 — Hollow diamond pattern (variation 23)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-024 — Checkerboard pattern (alternating * and spaces) (variation 24)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-025 — Spiral number pattern (variation 25)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-026 — Zigzag pattern (variation 26)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-027 — Arrow pattern pointing right (variation 27)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-028 — X pattern (two diagonals) (variation 28)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-029 — Rhombus pattern (variation 29)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-030 — Heart shape pattern (variation 30)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-031 — Number pyramid with centered alignment (variation 31)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-032 — Hollow triangle pattern (variation 32)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-033 — Reverse Floyd's triangle (variation 33)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-034 — Binary triangle (alternating 0 and 1) (variation 34)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-035 — Cross (+) pattern (variation 35)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-036 — Crown pattern (variation 36)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-037 — Wave pattern (variation 37)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-038 — Staircase pattern (variation 38)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-039 — Hourglass with numbers (variation 39)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-040 — Matrix spiral order print (variation 40)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-041 — Right triangle with numbers instead of stars (variation 41)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-042 — Inverted pyramid with descending numbers (variation 42)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-043 — Hollow diamond pattern (variation 43)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-044 — Checkerboard pattern (alternating * and spaces) (variation 44)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-045 — Spiral number pattern (variation 45)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-046 — Zigzag pattern (variation 46)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-047 — Arrow pattern pointing right (variation 47)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-048 — X pattern (two diagonals) (variation 48)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-049 — Rhombus pattern (variation 49)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-050 — Heart shape pattern (variation 50)

  • Level: Beginner
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-051 — Number pyramid with centered alignment (variation 51)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-052 — Hollow triangle pattern (variation 52)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-053 — Reverse Floyd's triangle (variation 53)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-054 — Binary triangle (alternating 0 and 1) (variation 54)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-055 — Cross (+) pattern (variation 55)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-056 — Crown pattern (variation 56)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-057 — Wave pattern (variation 57)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-058 — Staircase pattern (variation 58)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-059 — Hourglass with numbers (variation 59)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-060 — Matrix spiral order print (variation 60)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-061 — Right triangle with numbers instead of stars (variation 61)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-062 — Inverted pyramid with descending numbers (variation 62)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-063 — Hollow diamond pattern (variation 63)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-064 — Checkerboard pattern (alternating * and spaces) (variation 64)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-065 — Spiral number pattern (variation 65)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-066 — Zigzag pattern (variation 66)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-067 — Arrow pattern pointing right (variation 67)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-068 — X pattern (two diagonals) (variation 68)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-069 — Rhombus pattern (variation 69)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-070 — Heart shape pattern (variation 70)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-071 — Number pyramid with centered alignment (variation 71)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-072 — Hollow triangle pattern (variation 72)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-073 — Reverse Floyd's triangle (variation 73)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-074 — Binary triangle (alternating 0 and 1) (variation 74)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-075 — Cross (+) pattern (variation 75)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-076 — Crown pattern (variation 76)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-077 — Wave pattern (variation 77)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-078 — Staircase pattern (variation 78)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-079 — Hourglass with numbers (variation 79)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-080 — Matrix spiral order print (variation 80)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-081 — Right triangle with numbers instead of stars (variation 81)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-082 — Inverted pyramid with descending numbers (variation 82)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-083 — Hollow diamond pattern (variation 83)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-084 — Checkerboard pattern (alternating * and spaces) (variation 84)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-085 — Spiral number pattern (variation 85)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-086 — Zigzag pattern (variation 86)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-087 — Arrow pattern pointing right (variation 87)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-088 — X pattern (two diagonals) (variation 88)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-089 — Rhombus pattern (variation 89)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-090 — Heart shape pattern (variation 90)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-091 — Number pyramid with centered alignment (variation 91)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-092 — Hollow triangle pattern (variation 92)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-093 — Reverse Floyd's triangle (variation 93)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-094 — Binary triangle (alternating 0 and 1) (variation 94)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-095 — Cross (+) pattern (variation 95)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-096 — Crown pattern (variation 96)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-097 — Wave pattern (variation 97)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-098 — Staircase pattern (variation 98)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-099 — Hourglass with numbers (variation 99)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-100 — Matrix spiral order print (variation 100)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-101 — Right triangle with numbers instead of stars (variation 101)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-102 — Inverted pyramid with descending numbers (variation 102)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-103 — Hollow diamond pattern (variation 103)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-104 — Checkerboard pattern (alternating * and spaces) (variation 104)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-105 — Spiral number pattern (variation 105)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-106 — Zigzag pattern (variation 106)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-107 — Arrow pattern pointing right (variation 107)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-108 — X pattern (two diagonals) (variation 108)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-109 — Rhombus pattern (variation 109)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-110 — Heart shape pattern (variation 110)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-111 — Number pyramid with centered alignment (variation 111)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-112 — Hollow triangle pattern (variation 112)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-113 — Reverse Floyd's triangle (variation 113)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-114 — Binary triangle (alternating 0 and 1) (variation 114)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-115 — Cross (+) pattern (variation 115)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-116 — Crown pattern (variation 116)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-117 — Wave pattern (variation 117)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-118 — Staircase pattern (variation 118)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-119 — Hourglass with numbers (variation 119)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-120 — Matrix spiral order print (variation 120)

  • Level: Intermediate
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-121 — Right triangle with numbers instead of stars (variation 121)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-122 — Inverted pyramid with descending numbers (variation 122)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-123 — Hollow diamond pattern (variation 123)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-124 — Checkerboard pattern (alternating * and spaces) (variation 124)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-125 — Spiral number pattern (variation 125)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-126 — Zigzag pattern (variation 126)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-127 — Arrow pattern pointing right (variation 127)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-128 — X pattern (two diagonals) (variation 128)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-129 — Rhombus pattern (variation 129)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-130 — Heart shape pattern (variation 130)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-131 — Number pyramid with centered alignment (variation 131)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-132 — Hollow triangle pattern (variation 132)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-133 — Reverse Floyd's triangle (variation 133)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-134 — Binary triangle (alternating 0 and 1) (variation 134)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-135 — Cross (+) pattern (variation 135)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-136 — Crown pattern (variation 136)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-137 — Wave pattern (variation 137)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-138 — Staircase pattern (variation 138)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-139 — Hourglass with numbers (variation 139)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-140 — Matrix spiral order print (variation 140)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-141 — Right triangle with numbers instead of stars (variation 141)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-142 — Inverted pyramid with descending numbers (variation 142)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-143 — Hollow diamond pattern (variation 143)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-144 — Checkerboard pattern (alternating * and spaces) (variation 144)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-145 — Spiral number pattern (variation 145)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-146 — Zigzag pattern (variation 146)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-147 — Arrow pattern pointing right (variation 147)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-148 — X pattern (two diagonals) (variation 148)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-149 — Rhombus pattern (variation 149)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-150 — Heart shape pattern (variation 150)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-151 — Number pyramid with centered alignment (variation 151)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-152 — Hollow triangle pattern (variation 152)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-153 — Reverse Floyd's triangle (variation 153)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-154 — Binary triangle (alternating 0 and 1) (variation 154)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-155 — Cross (+) pattern (variation 155)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-156 — Crown pattern (variation 156)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-157 — Wave pattern (variation 157)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-158 — Staircase pattern (variation 158)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-159 — Hourglass with numbers (variation 159)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-160 — Matrix spiral order print (variation 160)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-161 — Right triangle with numbers instead of stars (variation 161)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-162 — Inverted pyramid with descending numbers (variation 162)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-163 — Hollow diamond pattern (variation 163)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-164 — Checkerboard pattern (alternating * and spaces) (variation 164)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-165 — Spiral number pattern (variation 165)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-166 — Zigzag pattern (variation 166)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-167 — Arrow pattern pointing right (variation 167)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-168 — X pattern (two diagonals) (variation 168)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-169 — Rhombus pattern (variation 169)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.

7.2b-170 — Heart shape pattern (variation 170)

  • Level: Advanced
  • Outer loop: Controls the row (1 to n).
  • Inner loop(s): Controls spaces and characters per row.
  • Key insight: Derive the formula relating row index to character count.
  • Time complexity: O(n²) — two nested loops.
  • Practice: Code in both JS and C++, verify output matches expected pattern.