Hi👋SpeedAlgo • Deliberate Practice & Cognitive Ergonomics for Software Engineers

An interactive algorithm mastery and technical interview preparation platform published by Hi👋WebEnterprise. Built for senior and staff software engineers preparing for rigorous coding screens at top tech companies (FAANG/MAMAA).

13 Core Algorithmic Patterns & 225 Practice Problems

  • 1. Two Pointers (16 Paradigms, 43 Problems): Opposite ends, sorted pair sums, palindrome verification, trapping rain water, 3Sum, container with most water — includes the Sliding Window and Fast & Slow Pointers paradigms (contiguous subarray invariants, longest substrings, Floyd's cycle detection, linked list middle).
  • 2. Binary Search (9 Paradigms, 14 Problems): Monotonic predicate partitioning (feasible(x)), boundary search, rotated sorted arrays, square roots, minimum ship capacity, median of two sorted arrays, matrix median on value range.
  • 3. Bit Manipulation (5 Paradigms, 11 Problems): Counting set bits, XOR cancellation, bit reversal, bitmask pairing, maximum XOR with a bitwise trie.
  • 4. Math & Geometry (8 Paradigms, 14 Problems): Sieve of Eratosthenes, integer/roman conversions, modular arithmetic, geometric simulation.
  • 5. Tree/Graph Depth-First Search (15 Paradigms, 24 Problems): Path sums, lowest common ancestor, tree diameter, validating BSTs, tree DP (House Robber III, Binary Tree Cameras).
  • 6. Tree/Graph Breadth-First Search (5 Paradigms, 12 Problems): Level-order traversals, shortest path in unweighted graphs, zig-zag traversals, rotting oranges, word ladders.
  • 7. Graphs (12 Paradigms, 22 Problems): Topological sort, cycle detection, Dijkstra's algorithm, bipartite graph validation, network delay.
  • 8. Backtracking (6 Paradigms, 14 Problems): Subsets, permutations, combinations, constraint satisfaction, pruning, N-Queens, Sudoku solver.
  • 9. Dynamic Programming (13 Paradigms, 28 Problems): Memoization vs tabulation, 0/1 knapsack, unbounded knapsack, coin change, edit distance, longest common subsequence.
  • 10. Heap / Priority Queue (9 Paradigms, 11 Problems): Running medians, top-k elements, interval scheduling, IPO, k-way merges.
  • 11. Advanced Data Structures (7 Paradigms, 17 Problems): Trie (prefix tree), Union-Find (Disjoint Set Union), LRU Cache, LFU Cache, range-sum queries with updates.
  • 12. Stack (5 Paradigms, 9 Problems): Next greater element, largest rectangle in histogram, remove k digits, decode string, min stack.
  • 13. Intervals & Greedy (2 Paradigms, 6 Problems): Merge intervals, interval scheduling, meeting rooms by sweep line, jump game.

4-Stage Deliberate Practice Framework

  1. Stage 1 (Compare & Learn): Read the pattern's mental model, loop invariant and Big-O proof, compare the pattern's template with the problem's solution side by side, and use the step-by-step debugger. The solution can also be shown in C#, Java, TypeScript, C++, Go or Rust for almost every problem.
  2. Stage 2 (Active Recall): Rebuild the solution from memory in a code editor, with an invariant checklist and optional progressive hints, and check it against a judged test suite.
  3. Stage 3 (AI Interview Coach, coming soon): A mock-interview stage still in development; for now, students go straight from Stage 2 to Stage 4.
  4. Stage 4 (Solve on Your Own): Solve a new problem on your own against a 15-minute timer; your code is graded against a test suite. Python and TypeScript run in your browser and C# runs on our server (design problems grade in Python and TypeScript).

Equipped with a spaced-repetition review hub on a fixed 7-step schedule (1 day up to 90 days), a two-pane Studio workspace, and study notes.

Pricing, Access & Commercial Terms

  • Core Curriculum: 100% Free. No credit card required.
  • Coins: New accounts get 40 free coins once, the daily claim adds +20 coins once a day, and inviting a friend earns you +25 coins when they complete their first practice step. These are the only ways to earn coins.
  • AI Coach: Each AI coach question costs 1-5 coins, priced by the server according to its size.
  • BYOK (Bring Your Own Key): AI coaching is free with your own Google Gemini, OpenAI or OpenRouter API key (BYOK).
  • Extras: Coins also unlock extras for 24 hours: a Recall hint level (1 coin), a Solve solution reveal (2), a LeetCode problem card's solutions (1) and a pattern's extra canonical problems (1).
  • Payments & Refunds: Nothing on the site is sold for money: coins can only be earned, never bought. There are no subscriptions or charges, so there is nothing to refund.
  • Platform Operator: Hi👋WebEnterprise. Support & policies at hispeedalgo.com.
Skip to main content
Hi👋SpeedAlgo

Invariant-First Algorithmic Mastery

Arena
238Items
Theory Context•Dynamic Programming
HardLC 44

Wildcard Matching (LeetCode 44)

Target Frequency:MetaAmazonGoogleApple

You're given a text string s and a wildcard pattern p built from ordinary characters plus two special symbols: '?', standing in for any one character, and '*', standing in for any run of characters, including an empty one.

Decide whether p matches s from the first character all the way to the last -- a partial match doesn't count.

Worked Examples

Example 1
Input:s = "aa", p = "a"
Output:false
Explanation: "a" does not match the entire string "aa".
Example 2
Input:s = "aa", p = "*"
Output:true
Explanation: '*' matches any sequence.
Example 3
Input:s = "cb", p = "?a"
Output:false
Explanation: The '?' covers the 'c', but the pattern's literal 'a' doesn't line up with the string's 'b', so the match fails.

⚖️Formal Constraints & Bounds

  • 0 <= s.length, p.length <= 2000

  • s contains only lowercase English letters.

  • p contains only lowercase English letters, '?' or '*'.

Deep-Dive & Conceptual Insights

Core Insight

'*' must check TWO transitions simultaneously -- 'consume one more source character and stay on the same * ' (dp[i-1][j]) or 'match the empty sequence and move past the ' (dp[i][j-1]) -- while the base row only stays True through a leading run of '' characters.

Real-World Scenario & Production Applications

Shell glob-style filename matching (*.txt, report_?.csv), search-box wildcard filters.

Subproblems & Recurrence Decomposition3 Phases

🧩Subproblem 1: Boolean Match-Grid Base Case

Define dp[i][j] as True iff s[:i] fully matches p[:j]. The empty string only matches a pattern prefix consisting entirely of '*' characters, so the base row stays True only through a leading run of '*'.

Mathematical Recurrence / Code Invariant
dp = [[False] * (N + 1) for _ in range(M + 1)]
dp[0][0] = True
for j in range(1, N + 1):
    dp[0][j] = dp[0][j - 1] if p[j - 1] == '*' else False

Step-by-Step Execution Trace Table

s prefixp prefixRule Applieddp Cell Value
""""Base caseTrue
"a""*"'*' matches empty (dp[0][0])True
"ad""ab*"'*' consumes one more char (dp[i-1][j])True
"adceb""ab*"Final cell: full matchTrue
Code Shape
Archetype Code Shape
Python
1dp = [[False]*(n+1) for _ in range(m+1)]
2dp[0][0] = True
3for j in range(1, n + 1):
4 dp[0][j] = dp[0][j-1] if p[j-1] == '*' else False
5for i in range(1, m + 1):
6 for j in range(1, n + 1):
7 if p[j-1] in ('?', s[i-1]):
8 dp[i][j] = dp[i-1][j-1]
9 elif p[j-1] == '*':
10 dp[i][j] = dp[i-1][j] or dp[i][j-1]
11 else:
12 dp[i][j] = False
13return dp[m][n]

Conceptual Narrative

Wildcard Matching is a harder Dual Sequence DP problem: the pattern language has only two symbols ('?' and ''), but the recurrence has a subtle trap around consecutive '' characters.

🧭 Conceptual Foundation & Pattern Intuition

Unlike Edit Distance where every cell picks the cheapest of three fixed operations, Wildcard Matching's grid answers a yes/no question: "can pattern prefix p[:j] match string prefix s[:i]?" The '?' character is trivial -- it behaves exactly like a guaranteed literal match, consuming one character from each side and inheriting the diagonal cell. The '' character is where the trap lives: it can match a sequence of any length, including zero, so cell (i, j) must ask two different questions simultaneously -- "does '' consume this source character and still match?" (dp[i-1][j]) OR "does '*' match nothing at all here?" (dp[i][j-1]).

🌟 The Analogy: A Rubber Band Wildcard

Think of '' as a stretchy rubber band that can shrink to zero width or stretch to cover any number of source characters. At each grid cell touching a '', you ask: "could I let the rubber band stretch one more character to the left (dp[i-1][j], keep the same '' and let it cover one more source character) or could I let the rubber band snap all the way to zero width right here (dp[i][j-1], move past the '' entirely)?" If either is true, the cell is true.

🔑 The Key Idea in the Code

The base row dp[0][j] is the classic trap: since '' can match empty, a pattern of ALL '' characters (e.g. "***") can still match the empty string, so dp[0][j] = dp[0][j-1] only while every preceding pattern character is '' -- the first non-'' character permanently zeroes out that row.

  • Leading pattern asterisks base case: Only setting dp[0][0] = True and failing to account for leading * in the pattern. A pattern like **** matches an empty string "". Set dp[0][j] = dp[0][j-1] while p[j-1] == '*'.

  • * dual-transition omission: Implementing * as only matching empty or only matching a single character. An asterisk matches empty (dp[i][j-1]) OR extends to match one more character (dp[i-1][j]). Both branches must be OR'd: dp[i][j] = dp[i][j-1] or dp[i-1][j].

  • ? wildcard character mismatch: Treating ? as matching zero or more characters. ? strictly matches exactly one arbitrary character; it cannot match an empty string.

Senior SWE Reasoning Architecture

4-Phase Thought Process Model

Pattern Recognition Signals

The 10-second spot

Boolean full-string match against a pattern containing '?' (any one char) and '*' (any sequence, including empty).

Formulating the Predicate & Invariants

Turning intuition into a boolean rule

Invariant: dp[i][j] is True iff s[:i] can be fully matched by p[:j].

Silent Failure Traps & Edge Cases

Where confident candidates still lose points

  • Forgetting the base row: dp[0][j] stays True only through a leading run of consecutive '*' characters, then permanently False.

  • Only checking dp[i-1][j-1] for '*' instead of the two-way OR of dp[i-1][j] (consume) and dp[i][j-1] (match empty).

The 60-Second Interview Pitch

Say this out loud before you type a single line

"I build an (m+1) x (n+1) boolean grid with dp[0][0] = True. The base row handles leading '' runs: dp[0][j] = dp[0][j-1] only while p[j-1] == '*'. For each cell, '?' or a literal match inherits dp[i-1][j-1]; '' is True if either dp[i-1][j] (consume one more source char) or dp[i][j-1] (match empty) is True. Runs in O(M · N) time and O(M · N) space."

Big-O Invariant Derivation

Complexity & Mathematical Proof

TIME COMPLEXITY

O(M · N)

Look at the execution steps: 2D boolean DP table for string s of length M and pattern p of length N. Each cell does O(1) work: either inherit a diagonal, or OR two neighboring cells for '*'.

SPACE COMPLEXITY

O(M · N) Auxiliary

Look at memory allocations: Call stack uses O(1) Iterative. Full (M+1) x (N+1) boolean grid retained (can be rolled to O(N) with two 1D rows).

Formal Recurrence Relation

T(M, N) = M · N = O(M · N)

Derivation Progression

Literal / '?' Transition

dp[i][j] = dp[i-1][j-1]

O(1) diagonal inheritance when characters match or pattern char is '?'.

'*' Two-Way Branch

dp[i][j] = dp[i-1][j] or dp[i][j-1]

O(1) OR of 'consume one more source char' and 'match empty sequence'.

Full Grid Fill

O(M · N) total cells

Every cell computed exactly once in row-major order.

Variable Definitions

MMM

Length of the input string s

NNN

Length of the pattern p

Memory Architecture & Bounds

🟣 Call Stack

O(1) Iterative

🔵 Auxiliary Heap

O(M · N) boolean grid (or O(N) with rolling rows)

🟢 Output Space

O(1) boolean result

Boundary Best / Worst Cases

Best Case

O(M⋅N)O(M · N)O(M⋅N)

Average Case

O(M⋅N)O(M · N)O(M⋅N)

Worst Case

O(M⋅N)O(M · N)O(M⋅N)

State-Space & Subproblem DAG(Directed Acyclic Graph) Topology

State-Space & Subproblem DAG(Directed Acyclic Graph) Topology
Synthesizing vector architecture diagram...
Staff+ Engineering Perspective

Senior SWE Deconstruction & Hardware Caveats

ARCHITECTURAL SIGNALS & INTERVIEW TRIGGERS

Triggers: "'?' matches single char", "'*' matches any sequence of chars". 2D boolean matching table: - If p[j−1]==′∗′p[j-1] == '*'p[j−1]==′∗′: dp[i][j] = dp[i-1][j] (star absorbs current character) or dp[i][j-1] (star matches empty sequence). - If p[j−1]==′?′p[j-1] == '?'p[j−1]==′?′ or matches char: dp[i][j] = dp[i-1][j-1].

CONSTRAINTS & BOUNDS

s,p≤2000s, p \le 2000s,p≤2000. Budget O(MN)O(MN)O(MN).

Theory Context•Dynamic Programming
HardLC 44

Wildcard Matching (LeetCode 44)

Target Frequency:MetaAmazonGoogleApple

You're given a text string s and a wildcard pattern p built from ordinary characters plus two special symbols: '?', standing in for any one character, and '*', standing in for any run of characters, including an empty one.

Decide whether p matches s from the first character all the way to the last -- a partial match doesn't count.

Worked Examples

Example 1
Input:s = "aa", p = "a"
Output:false
Explanation: "a" does not match the entire string "aa".
Example 2
Input:s = "aa", p = "*"
Output:true
Explanation: '*' matches any sequence.
Example 3
Input:s = "cb", p = "?a"
Output:false
Explanation: The '?' covers the 'c', but the pattern's literal 'a' doesn't line up with the string's 'b', so the match fails.

⚖️Formal Constraints & Bounds

  • 0 <= s.length, p.length <= 2000

  • s contains only lowercase English letters.

  • p contains only lowercase English letters, '?' or '*'.

Deep-Dive & Conceptual Insights

Core Insight

'*' must check TWO transitions simultaneously -- 'consume one more source character and stay on the same * ' (dp[i-1][j]) or 'match the empty sequence and move past the ' (dp[i][j-1]) -- while the base row only stays True through a leading run of '' characters.

Real-World Scenario & Production Applications

Shell glob-style filename matching (*.txt, report_?.csv), search-box wildcard filters.

Subproblems & Recurrence Decomposition3 Phases

🧩Subproblem 1: Boolean Match-Grid Base Case

Define dp[i][j] as True iff s[:i] fully matches p[:j]. The empty string only matches a pattern prefix consisting entirely of '*' characters, so the base row stays True only through a leading run of '*'.

Mathematical Recurrence / Code Invariant
dp = [[False] * (N + 1) for _ in range(M + 1)]
dp[0][0] = True
for j in range(1, N + 1):
    dp[0][j] = dp[0][j - 1] if p[j - 1] == '*' else False

Step-by-Step Execution Trace Table

s prefixp prefixRule Applieddp Cell Value
""""Base caseTrue
"a""*"'*' matches empty (dp[0][0])True
"ad""ab*"'*' consumes one more char (dp[i-1][j])True
"adceb""ab*"Final cell: full matchTrue
Code Shape
Archetype Code Shape
Python
1dp = [[False]*(n+1) for _ in range(m+1)]
2dp[0][0] = True
3for j in range(1, n + 1):
4 dp[0][j] = dp[0][j-1] if p[j-1] == '*' else False
5for i in range(1, m + 1):
6 for j in range(1, n + 1):
7 if p[j-1] in ('?', s[i-1]):
8 dp[i][j] = dp[i-1][j-1]
9 elif p[j-1] == '*':
10 dp[i][j] = dp[i-1][j] or dp[i][j-1]
11 else:
12 dp[i][j] = False
13return dp[m][n]

Conceptual Narrative

Wildcard Matching is a harder Dual Sequence DP problem: the pattern language has only two symbols ('?' and ''), but the recurrence has a subtle trap around consecutive '' characters.

🧭 Conceptual Foundation & Pattern Intuition

Unlike Edit Distance where every cell picks the cheapest of three fixed operations, Wildcard Matching's grid answers a yes/no question: "can pattern prefix p[:j] match string prefix s[:i]?" The '?' character is trivial -- it behaves exactly like a guaranteed literal match, consuming one character from each side and inheriting the diagonal cell. The '' character is where the trap lives: it can match a sequence of any length, including zero, so cell (i, j) must ask two different questions simultaneously -- "does '' consume this source character and still match?" (dp[i-1][j]) OR "does '*' match nothing at all here?" (dp[i][j-1]).

🌟 The Analogy: A Rubber Band Wildcard

Think of '' as a stretchy rubber band that can shrink to zero width or stretch to cover any number of source characters. At each grid cell touching a '', you ask: "could I let the rubber band stretch one more character to the left (dp[i-1][j], keep the same '' and let it cover one more source character) or could I let the rubber band snap all the way to zero width right here (dp[i][j-1], move past the '' entirely)?" If either is true, the cell is true.

🔑 The Key Idea in the Code

The base row dp[0][j] is the classic trap: since '' can match empty, a pattern of ALL '' characters (e.g. "***") can still match the empty string, so dp[0][j] = dp[0][j-1] only while every preceding pattern character is '' -- the first non-'' character permanently zeroes out that row.

  • Leading pattern asterisks base case: Only setting dp[0][0] = True and failing to account for leading * in the pattern. A pattern like **** matches an empty string "". Set dp[0][j] = dp[0][j-1] while p[j-1] == '*'.

  • * dual-transition omission: Implementing * as only matching empty or only matching a single character. An asterisk matches empty (dp[i][j-1]) OR extends to match one more character (dp[i-1][j]). Both branches must be OR'd: dp[i][j] = dp[i][j-1] or dp[i-1][j].

  • ? wildcard character mismatch: Treating ? as matching zero or more characters. ? strictly matches exactly one arbitrary character; it cannot match an empty string.

Senior SWE Reasoning Architecture

4-Phase Thought Process Model

Pattern Recognition Signals

The 10-second spot

Boolean full-string match against a pattern containing '?' (any one char) and '*' (any sequence, including empty).

Formulating the Predicate & Invariants

Turning intuition into a boolean rule

Invariant: dp[i][j] is True iff s[:i] can be fully matched by p[:j].

Silent Failure Traps & Edge Cases

Where confident candidates still lose points

  • Forgetting the base row: dp[0][j] stays True only through a leading run of consecutive '*' characters, then permanently False.

  • Only checking dp[i-1][j-1] for '*' instead of the two-way OR of dp[i-1][j] (consume) and dp[i][j-1] (match empty).

The 60-Second Interview Pitch

Say this out loud before you type a single line

"I build an (m+1) x (n+1) boolean grid with dp[0][0] = True. The base row handles leading '' runs: dp[0][j] = dp[0][j-1] only while p[j-1] == '*'. For each cell, '?' or a literal match inherits dp[i-1][j-1]; '' is True if either dp[i-1][j] (consume one more source char) or dp[i][j-1] (match empty) is True. Runs in O(M · N) time and O(M · N) space."

Big-O Invariant Derivation

Complexity & Mathematical Proof

TIME COMPLEXITY

O(M · N)

Look at the execution steps: 2D boolean DP table for string s of length M and pattern p of length N. Each cell does O(1) work: either inherit a diagonal, or OR two neighboring cells for '*'.

SPACE COMPLEXITY

O(M · N) Auxiliary

Look at memory allocations: Call stack uses O(1) Iterative. Full (M+1) x (N+1) boolean grid retained (can be rolled to O(N) with two 1D rows).

Formal Recurrence Relation

T(M, N) = M · N = O(M · N)

Derivation Progression

Literal / '?' Transition

dp[i][j] = dp[i-1][j-1]

O(1) diagonal inheritance when characters match or pattern char is '?'.

'*' Two-Way Branch

dp[i][j] = dp[i-1][j] or dp[i][j-1]

O(1) OR of 'consume one more source char' and 'match empty sequence'.

Full Grid Fill

O(M · N) total cells

Every cell computed exactly once in row-major order.

Variable Definitions

MMM

Length of the input string s

NNN

Length of the pattern p

Memory Architecture & Bounds

🟣 Call Stack

O(1) Iterative

🔵 Auxiliary Heap

O(M · N) boolean grid (or O(N) with rolling rows)

🟢 Output Space

O(1) boolean result

Boundary Best / Worst Cases

Best Case

O(M⋅N)O(M · N)O(M⋅N)

Average Case

O(M⋅N)O(M · N)O(M⋅N)

Worst Case

O(M⋅N)O(M · N)O(M⋅N)

State-Space & Subproblem DAG(Directed Acyclic Graph) Topology

State-Space & Subproblem DAG(Directed Acyclic Graph) Topology
Synthesizing vector architecture diagram...
Staff+ Engineering Perspective

Senior SWE Deconstruction & Hardware Caveats

ARCHITECTURAL SIGNALS & INTERVIEW TRIGGERS

Triggers: "'?' matches single char", "'*' matches any sequence of chars". 2D boolean matching table: - If p[j−1]==′∗′p[j-1] == '*'p[j−1]==′∗′: dp[i][j] = dp[i-1][j] (star absorbs current character) or dp[i][j-1] (star matches empty sequence). - If p[j−1]==′?′p[j-1] == '?'p[j−1]==′?′ or matches char: dp[i][j] = dp[i-1][j-1].

CONSTRAINTS & BOUNDS

s,p≤2000s, p \le 2000s,p≤2000. Budget O(MN)O(MN)O(MN).

© 2026 Hi👋WebEnterprise. All rights reserved.
Sitemap•llms.txt•