Wildcard Matching

DP on Strings DSA practice problem on Onlearn.

Difficulty: medium.

Topics: Wildcard Matching Problem: Checking if a string matches a pattern with wildcards '?' and '*', Dynamic Programming, Memoization, Tabulation, Space Optimization, Recursion, Strings, Time Complexity, Space Complexity, Base Cases, Overlapping Subproblems, Optimal Substructure, Edge Cases, String Manipulation, string matching, dynamic programming, memoization, tabulation, space optimization, recursion, Subsequence Problems, String Matching DP.

Problem Statement Given two strings, s1 and s2, implement wildcard pattern matching with the following special characters: '?' matches any single character. ' ' matches any sequence of characters (including the empty sequence). The matching should cover the entire s2 (not partial). Input Specification The input consists of two strings: s1: The pattern string, which can contain lowercase English letters, '?', and ' '. s2: The text string, which contains only lowercase English letters. Output Specification Return true if s1 matches s2, otherwise return false. Sample Test Cases Example 1: Input: s1 = "ab cd" s2 = "abdefcd" Output: true Explanation: The ' ' in s1 can match the substring "def" in s2.