MEDIUMasked at 2 companies

Word Pattern II

A medium-tier problem at 49% community acceptance, tagged with Hash Table, String, Backtracking. Reported in interviews at Dropbox and 1 others.

Founder's read

Word Pattern II shows up in assessments at Dropbox and Oracle, and it's deceptively hard. You've probably crushed the first Word Pattern problem, but this one flips the script: instead of one character-to-word mapping, you're building a bidirectional mapping from a pattern string to an input string, and you don't know the word boundaries. The acceptance rate sits at just under 50%, which means half the candidates who attempt it walk away empty-handed. This is where backtracking bites people who haven't seen the constraint-satisfaction angle before. If this hits your live OA and you freeze on how to iterate without knowing splits, StealthCoder surfaces the solution invisible to the proctor.

Companies asking
2
Difficulty
MEDIUM
Acceptance
49%

Companies that ask "Word Pattern II"

If this hits your live OA

Word Pattern II 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 an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.

Get StealthCoder
What this means

The trick is backtracking with a two-way hash table. Most candidates try greedy or dynamic programming first, both dead ends. You must recursively try every possible split of the input string against the pattern, maintaining a bijection (one-to-one mapping) between characters and words: if 'a' maps to 'hello', no other character can also map to 'hello', and 'a' can't map to anything else. The moment a mapping violates the bijection, backtrack. Many stumble on the bidirectional check or forget to undo the mapping when they backtrack. Common pitfalls: not tracking which words have been used, mapping the same character to different words on different branches, or trying to solve it without backtracking at all. This is pure constraint satisfaction wrapped in string manipulation. Hash Table and Backtracking are the real topics here; String is just the input format. When you hit this live and your first approach fails, StealthCoder runs the backtracking solution invisible to the screen share.

Pattern tags

The honest play

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

Word Pattern II 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. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Word Pattern II interview FAQ

Is Word Pattern II really harder than Word Pattern I?+

Yes, objectively. Word Pattern I gives you fixed word boundaries from a space-separated string. Word Pattern II strips those boundaries, forcing you to discover them via backtracking. The acceptance rate (48.6%) reflects that jump. This problem demands constraint-satisfaction thinking, not just hash table lookup.

What's the backtracking structure I need?+

Recursively try every possible next word from the current position in the input string. For each candidate word, check if it violates the pattern-to-word or word-to-pattern mapping. If it fits, map it, recurse, then undo the mapping. Base case: pattern index and input index both exhausted. Undo is the critical step most candidates miss.

Why can't I just use DP or greedy?+

DP requires you to define subproblems with no word-boundary overlap, but you don't know boundaries upfront. Greedy tries to commit to the first valid mapping and fails when a later constraint forces a different split. Backtracking is the only approach that explores all valid mappings within the constraints.

What's the bijection constraint and why does it trip people up?+

Each pattern character maps to exactly one word, and each word maps back to exactly one character. If 'a' is 'hello', then 'b' can't also be 'hello', and 'a' can't become 'world' later. Most candidates track only one direction (char to word) and forget the reverse check, leading to false positives.

Is Word Pattern II asked often at FAANG and similar shops?+

Reported from Dropbox and Oracle. The 48.6% acceptance rate and medium difficulty suggest it's more niche than classic backtracking problems, but it's a go-to pattern-matching question when they want to test constraint satisfaction and mapping logic.

Want the actual problem statement? View "Word Pattern II" 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.