Match Pattern
Reported by candidates from Uber's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Uber's Match Pattern question hit the assessment circuit in August 2024, and it's a string-matching problem that looks deceptively simple on the surface. You get a pattern and a string, and you need to determine if they match according to specific wildcard rules. The trap is that most candidates either overthink the state transitions or miss edge cases with consecutive wildcards. If you blank during the live OA, StealthCoder will feed you the core logic in real time so you can write confident code instead of guessing.
Pattern and pitfall
This is a classic dynamic programming problem disguised as a string matching question. You build a 2D DP table where dp[i][j] represents whether the first i characters of the string match the first j characters of the pattern. The trick is handling wildcards correctly: a dot matches any single character, and a star matches zero or more of the preceding element. Most candidates fail because they don't account for the zero-occurrence case (where star matches nothing) or they get the recurrence relation wrong. StealthCoder watches you type and catches these off-by-one errors in the indices before they cost you the test.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Match Pattern cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as regular expression matching. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Uber's OA.
Uber reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Match Pattern FAQ
Is this actually regex matching or something simpler?+
It's a constrained regex problem. Typically dot matches exactly one character and star matches zero or more of the preceding character. Not full regex syntax. The pattern string has at most a few dozen characters, so brute force DP is the intended solution.
What's the most common mistake candidates make?+
Forgetting that star can match zero occurrences. When you see pattern[j-1] == '*', you need to check both dp[i][j-2] (skip the star entirely) and dp[i-1][j] (use the star again). Missing either branch breaks your logic.
Can I solve this with recursion and memoization instead of bottom-up DP?+
Yes. Define a recursive function isMatch(s, p, i, j) and memoize on (i, j). Top-down is often clearer during a live interview because you can reason about the base cases first. Both approaches are O(m*n) time and space.
How much time should I budget for this problem?+
If you know the pattern, 15-20 minutes to code and test. If you're stuck on the recurrence, you'll lose 30+ minutes. That's where StealthCoder helps: it nudges you past the first block so you finish strong.
Will Uber ask follow-ups if I solve it quickly?+
Possibly. Common follow-ups include handling additional wildcards (like plus for one-or-more) or optimizing space. But solve the base problem cleanly first. A working solution beats a half-thought optimization attempt.