Filter Reusable-Character Word Skeletons
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 <= 10000 <= skeletons.length <= 100000