Filter Reusable-Character Word Skeletons
Reported by candidates from ZipRecruiter's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure that carries this ZipRecruiter problem, reported in October 2023, is a plain set of characters, built once per skeleton. The task: given a word and a list of skeleton strings, keep the ones that match, in order, duplicates included. Fixed letters must line up with the word exactly. Each dash can only become a letter that already appears as a fixed letter in that same skeleton. It's a string problem that looks fussy and isn't. If you blank during the OA, StealthCoder is the invisible safety net that reads the prompt and hands you the logic in real time.
The problem
word and every skeleton have equal length. Fixed lowercase letters must match word at their positions. Each - may be replaced only by a character occurring as a fixed letter in that same skeleton. Return matching skeletons in input order, retaining duplicates. Function filterWordSkeletons(word: String, skeletons: String[]) → String[] Examples Example 1 word = "hello" skeletons = ["he-lo","he--o","-ell-","hello"] return = ["he-lo","hello"] he-lo can reuse fixed l; hello already matches. Example 2 word = "aaa" skeletons = ["a--","---"] return = ["a--"] a-- can reuse a; --- has no fixed letter. Constraints 1 <= word.length <= 1000 0 <= skeletons.length <= 100000
Reported by candidates. Source: FastPrep
Pattern and pitfall
Two passes per skeleton. Pass one: walk the characters, and for each non-dash character check it equals word at that index. If it fails, reject. Otherwise add it to a set of fixed letters. Pass two: for each dash, the word's character at that position must be in the set. If any isn't, reject. Keep the skeleton if both passes survive. The pitfall is building the set from the word instead of from the skeleton, or checking dashes before the set is complete. Example 2 shows it: "---" has no fixed letters, so every dash fails. Another trap is deduping the output. Don't. Duplicates stay, order stays. Cost is O(L) per skeleton, so total is O(N*L), and with up to 100000 skeletons that's fine. If you freeze live, StealthCoder is your hedge for the actual OA, but the logic above is short enough to hold in your head.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Filter Reusable-Character Word Skeletons 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. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass ZipRecruiter's OA.
ZipRecruiter reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Filter Reusable-Character Word Skeletons FAQ
What's the trick in the ZipRecruiter skeleton filtering problem?+
Build a set of the fixed letters in each skeleton, and verify every fixed letter matches the word at its index. Then every dash position needs the word's letter to be in that set. Two simple passes per skeleton, no fancy structure needed.
How hard is this problem really?+
Easy to medium. The logic is short, but the rules are worded in a confusing way. Most mistakes come from misreading which set the dash letters come from. Trace Example 1 by hand once and the rest follows.
Should I remove duplicate skeletons from the output?+
No. The prompt says to return matching skeletons in input order and retain duplicates. So just iterate the list once, test each skeleton independently, and append the passing ones as they come.
What edge cases should I test?+
An all-dash skeleton, which always fails since it has no fixed letters. A skeleton with no dashes, which passes only if it equals the word. An empty skeleton list, which returns an empty list. Also a fixed letter that mismatches the word.
How do I prepare for this in 48 hours?+
Write the two-pass check from memory twice, using a set and a loop over indices. Then test it on both examples. Also review general string iteration and set membership. This pattern is small enough that a couple of clean runs is enough prep.