Search⌘ K
AI Features

Solution: Wildcard Matching

Understand how to implement a greedy algorithm for wildcard matching that uses '?' and '*' to match an entire input string. Explore a two-pointer approach with backtracking to handle patterns flexibly while maintaining optimal time and space complexity. Learn to return true only when the entire string matches the pattern.

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.

...