Uber | Phone Screen | Wildcard Pattern Matching

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2019-11-05Added By Anonymous
Source: Link

Interview Stage: Phone Screen


Original Post Content:


Given a `text` and a wildcard `pattern`, implement wildcard pattern matching algorithm that finds if wildcard pattern is matched with text. The matching should cover the entire text (not partial text).

The wildcard pattern can include only `?` – matches 0 or 1 of previous character.


Example 1:


Input: pattern = "be?t", text = "bet"

Output: true


Example 2:


Input: pattern = "ton?e?", text = "'to"

Output: true


Example 3:

Input: pattern = "ton?e?", text = "tonne"

Output: false

Related problems:

https://leetcode.com/problems/wildcard-matching/

Comments