FastPrepFilter Reusable-Character Word Skeletons

Filter Reusable-Character Word Skeletons

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA
Learn

Problem statement

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

More ZipRecruiter problems

See ZipRecruiter hiring insights
public String[] filterWordSkeletons(String word, String[] skeletons) {
    // Write your code here.
}
word"hello"
skeletons["he-lo","he--o","-ell-","hello"]
expected["he-lo", "hello"]
Checking account…