Spelling Bee Word Filter
Updated
Problem statement
You are given an array of unique lowercase words dictionary, a one-character string required, and a six-character string optional.
Return every dictionary word that satisfies all of these rules:
- The word contains at least four letters.
- The required letter appears at least once.
- Every character is either the required letter or one of the optional letters.
- Allowed letters may be repeated any number of times.
Preserve the words' original dictionary order.
Function
spellingBeeWords(dictionary: String[], required: String, optional: String) → String[]Examples
Example 1
dictionary = ["encode","nonce","done","node","oven","deed","coded","envy","no"]required = "n"optional = "vcodey"return = ["encode","nonce","done","node","oven","envy"]deed and coded omit the required letter, while no is too short.
Example 2
dictionary = ["pole","tone","toll","gone","trope","ton","google","people","noon","longer"]required = "o"optional = "gleptn"return = ["pole","tone","toll","gone","google","people","noon"]ton is shorter than four letters. trope and longer contain the disallowed letter r.
Example 3
dictionary = []required = "a"optional = "bcdefg"return = []An empty dictionary has no matching words.
Constraints
0 <= dictionary.length <= 100000.- Every dictionary word is unique, nonempty, and contains only lowercase English letters.
- The total number of characters across
dictionaryis at most1000000. requiredcontains exactly one lowercase English letter.optionalcontains exactly six distinct lowercase English letters, none equal torequired.
More Bloomberg LP Phone Screen questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Repeated DNA SequencesNVIDIA · PHONE SCREENNVIDIA interview questions
- Numeric Wildcard Dictionary MatchingHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
- Palindrome-Rearrangeable PairsExpedia · OAExpedia interview questions
- Palindrome PermutationRippling · OARippling interview questions
- Password Clues and the Next CommandOpenAI · OAOpenAI interview questions
- Count Magical Adjacent Substring TripletsGoogle · ONSITE INTERVIEWGoogle interview questions
- Longest Substring with Even OccurrencesDeloitte · OADeloitte interview questions
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- First Letter to Appear TwiceCisco · PHONE SCREENCisco interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)