MEDIUMasked at 1 company

Find and Replace Pattern

A medium-tier problem at 77% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Zomato and 0 others.

Founder's read

You're staring at a list of words and a pattern, and the problem wants you to find every word that matches it. This is exactly the kind of problem that sounds simple until you realize the pattern matching logic is tricky. Zomato has asked this, and it shows up in OAs where they're testing whether you can handle string-to-string character mapping under constraints. The acceptance rate sits around 77 percent, which means most people solve it, but plenty hit a wall on the isomorphism logic or the bidirectional mapping requirement. If this hits your live assessment and you blank on the trick, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
1
Difficulty
MEDIUM
Acceptance
77%

Companies that ask "Find and Replace Pattern"

If this hits your live OA

Find and Replace Pattern 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. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.

Get StealthCoder
What this means

The core trap is thinking character matching is one-way. It's not. When you map a character in the pattern to a character in the word, you must enforce that no two pattern characters map to the same word character, and no two word characters map to the same pattern character. This bidirectional constraint eliminates naive approaches. You'll iterate through each word, build the mapping as you scan left to right, and reject any word where the constraints break. Most candidates miss the reverse lookup and end up with false positives. The solution uses a hash table (or two, for safety) to track both directions of the mapping simultaneously. Once you lock in the bidirectional constraint, the implementation is straightforward. This problem tests disciplined map-building more than algorithmic insight, which is why StealthCoder is the hedge if the pattern-matching pattern doesn't click before you go live.

Pattern tags

The honest play

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

Find and Replace Pattern recycles across companies for a reason. It's medium-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. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find and Replace Pattern interview FAQ

What does the pattern matching actually mean here?+

Every character in the pattern maps to exactly one character in the word, and vice versa. If the pattern is 'foo' and the word is 'bar', then 'f' maps to 'b' and 'o' maps to 'a' and 'o' maps to 'r'. But 'o' can't map to two different characters. So 'foo' doesn't match 'bar' because that violates the one-to-one rule.

Why does a one-way hash table fail?+

If you only track pattern-to-word mappings, two different pattern characters can map to the same word character. For example, pattern 'ab' and word 'aa' both get admitted because 'a' maps to 'a' and 'b' maps to 'a', but that violates the bijection. You need a reverse lookup to catch this.

Is this really asked by companies like Zomato?+

Yes. Zomato has confirmed this problem in their OA. It's a medium-difficulty pattern-matching problem that tests careful constraint handling, not heavy algorithms. It appears in coding rounds where they want to see if you can implement logic correctly under multiple conditions.

What's the time complexity?+

If you have n words and each word has length m, you're iterating through each word once and checking each character. Hash table lookups are O(1), so the overall complexity is O(n times m). Space is O(1) for the mapping hash tables since the alphabet is fixed.

Is this problem still frequently asked?+

It appears in a steady stream of OAs and technical interviews, especially at mid-size tech companies and startups. The acceptance rate of 77 percent suggests it's not a trap problem, but the bidirectional mapping constraint catches enough candidates that it's still a useful filter for coding assessments.

Want the actual problem statement? View "Find and Replace Pattern" 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.