Problem
Ask
Submissions

Problem: Wildcard Matching

Medium
30 min
Explore how to solve the wildcard matching problem by using greedy techniques. This lesson helps you implement pattern matching where '?' matches a single character and '*' matches any sequence of characters. Understand how to determine if a pattern completely matches an input string for coding interview preparation.

Statement

Given an input string, s, and a pattern string, p, implement wildcard pattern matching that determines if the pattern matches the entire input string.

The pattern supports two special wildcard characters:

  • '?': Matches exactly one arbitrary character.

  • '*': Matches any sequence of characters (including zero characters).

The match must be complete, meaning the pattern should cover the entire input string, not just a part of it.

Return TRUE if the pattern matches the whole string; otherwise, return FALSE.

Constraints:

  • 00 \leq s.length ,, p.length2000\leq 2000

  • s contains only lowercase English letters.

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

Problem
Ask
Submissions

Problem: Wildcard Matching

Medium
30 min
Explore how to solve the wildcard matching problem by using greedy techniques. This lesson helps you implement pattern matching where '?' matches a single character and '*' matches any sequence of characters. Understand how to determine if a pattern completely matches an input string for coding interview preparation.

Statement

Given an input string, s, and a pattern string, p, implement wildcard pattern matching that determines if the pattern matches the entire input string.

The pattern supports two special wildcard characters:

  • '?': Matches exactly one arbitrary character.

  • '*': Matches any sequence of characters (including zero characters).

The match must be complete, meaning the pattern should cover the entire input string, not just a part of it.

Return TRUE if the pattern matches the whole string; otherwise, return FALSE.

Constraints:

  • 00 \leq s.length ,, p.length2000\leq 2000

  • s contains only lowercase English letters.

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