Wildcard Pattern Matching Problem Statement

Implement a wildcard pattern matching algorithm to determine if a given wildcard pattern matches a text string completely.

The wildcard pattern may include the characters '?' and '*'.
'?' matches any single character.
'*' matches any sequence of characters, including zero characters.

Input:

The first line contains an Integer 'T', representing the number of test cases. For each test case: The first line contains a string representing the wildcard pattern. The second line contains a string representing the text.

Output:

Print 'True' if the text matches the pattern, otherwise print 'False'. Each result is printed on a new line for each test case.

Example:

Input:
T = 2
Pattern1 = "a*b?"
Text1 = "axyb"
Pattern2 = "*c"
Text2 = "abc"
Output:
True
False

Explanation:

For Pattern1 and Text1, each wildcard character matches appropriate characters, resulting in a match. For Pattern2 and Text2, there is no full match of characters leading to a 'False' result.

Constraints:

  • 1 ≤ T ≤ 100
  • 1 ≤ N ≤ 200
  • 1 ≤ M ≤ 200
  • 'TEXT' and 'PATTERN' consist only of lowercase letters and the special characters ‘*’ and ‘?’
  • Time Limit: 1 second
AnswerBot
1y

The task is to implement a wildcard pattern matching algorithm that checks if a given wildcard pattern matches a given text.

  • The wildcard pattern can include the characters '?' and '*'

  • '?' matches any s...read more

Help your peers!
Add answer anonymously...
NXP Semiconductors Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter