HARDasked at 19 companies

Wildcard Matching

A hard-tier problem at 30% community acceptance, tagged with String, Dynamic Programming, Greedy. Reported in interviews at Two Sigma and 18 others.

Founder's read

Wildcard Matching is one of those problems that looks deceptively simple until you hit it live and realize the greedy trick fails. It's asked by Two Sigma, X, Snap, and Instacart, among others, and sits at 29% acceptance. The problem: match a string against a pattern where '?' matches any single character and '*' matches any sequence (including empty). The naive recursive solution times out. The DP solution works but demands careful state management. If this lands on your OA and you blank on the two-pointer greedy optimization, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
19
Difficulty
HARD
Acceptance
30%

Companies that ask "Wildcard Matching"

If this hits your live OA

Wildcard Matching is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The gotcha is that '*' is greedy and can match zero or more characters, which creates exponential branching in recursion. DP works by building a table where dp[i][j] represents whether the first i characters of the string match the first j characters of the pattern. But the real speedup is the two-pointer greedy approach with backtracking: advance both pointers normally, mark where '*' occurs in the pattern, and when a mismatch happens, backtrack to the last '*' and let it consume one more character. This avoids the DP table overhead and handles edge cases like consecutive '*' cleanly. The trap is forgetting to handle the trailing '*' characters that can match empty strings at the end. When you're under pressure in the live assessment, the pattern logic unravels. That's where StealthCoder becomes your safety net.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Wildcard Matching recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Wildcard Matching interview FAQ

Is this really asked at FAANG and mid-market tech?+

Yes. Two Sigma, X, Snap, Instacart, Walmart Labs, and others have asked it. At 29% acceptance, it's a hard filter. Companies use it to screen for pattern recognition and DP fluency. If you see it, you're not in an easy round.

Why does the greedy approach beat DP?+

DP builds an O(m*n) table upfront. Greedy with backtracking is O(m+n) in the best case and avoids heap allocation. On large inputs, greedy is faster and uses less memory. But greedy logic is trickier to code correctly under time pressure.

What's the most common mistake candidates make?+

Forgetting that a '*' at the end of the pattern can match an empty suffix. Also, not handling multiple consecutive '*' characters. Recursion without memoization hits exponential time. Most fail on edge cases like pattern '*' matching any string, including empty.

How does this relate to Regex or other string problems?+

It's a simplified regex engine. Unlike Regular Expression Matching, there's no '.' metacharacter, only '?' and '*'. It's adjacent to Palindrome Partitioning and Longest Valid Parentheses in that it uses DP or greedy backtracking to avoid exponential branches.

If I blank on the pattern during the assessment, how long to recover?+

Coding a correct DP solution from scratch takes 20-30 minutes if you're calm. Greedy logic is faster to explain but slower to debug live. If you hit a wall, StealthCoder runs invisible during screen share and gives you a working solution to study and adapt.

Want the actual problem statement? View "Wildcard Matching" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.