Magic Dictionary Queries
Updated
Problem statement
You are given an array dictionary of distinct lowercase words and an array queries.
For each query, return true exactly when you can replace one character with a different lowercase letter so that the resulting word equals a word in dictionary. You may not insert, delete, or reorder characters.
An unchanged dictionary match does not satisfy the rule by itself. However, it still returns true when a different dictionary word of the same length differs from it in exactly one position.
Return the answers in query order.
Function
magicDictionaryQueries(dictionary: String[], queries: String[]) → boolean[]Examples
Example 1
dictionary = ["hello","leetcode"]queries = ["hello","hhllo","hell","leetcoded"]return = [false,true,false,false]hhllo becomes hello after one replacement. The exact word hello needs zero replacements, and changing length is forbidden.
Example 2
dictionary = ["hello","hallo"]queries = ["hello","hullo","hallo"]return = [true,true,true]Each query has a dictionary neighbor at Hamming distance exactly one. For example, exact match hello can change its second character to reach hallo.
Example 3
dictionary = ["a","ab","xyz"]queries = ["b","a","ac","xyy","xy"]return = [true,false,true,true,false]b, ac, and xyy each differ from a same-length dictionary word in exactly one position. No qualifying alternative exists for a, and xy has no same-length neighbor.
Constraints
1 <= dictionary.length, queries.length <= 100000.1 <= dictionary[i].length, queries[i].length <= 100.- All words contain only lowercase English letters.
- Words in
dictionaryare distinct. - The total number of characters across
dictionaryandqueriesis at most200000.
More Bloomberg LP Phone Screen questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- 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
Similar questions at other companies
- Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Group AnagramsWorkday · PHONE SCREEN
- Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
- Word BreakAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Group AnagramsEPAM · PHONE SCREENEPAM interview questions
- Underline Shortest Unique SubstringsMoveworks · PHONE SCREENMoveworks interview questions
- Find Duplicate File GroupsAnthropic · PHONE SCREENAnthropic interview questions
- Underline Shortest Unique SubstringsAtlassian · PHONE SCREENAtlassian interview questions
- Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo 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)