Get Search Results
Updated
Problem statement
Implement an autocorrect function that returns all words which are anagrams of a search query. An anagram is any string that can be formed by rearranging the letters of another string.
Given two arrays, words and queries of length n and q, respectively, for each query, return an array of strings that are anagrams of the query, sorted in alphabetical order.
Function
getSearchResults(words: String[], queries: String[]) → String[][]
Complete the function getSearchResults in the editor with the following arguments:
string words[n]: the list of words to searchstring queries[q]: the words to search for
Returns
string[q][]: the results for each search query
Grateful beyond words to a wonderful old friend for your kind and generous help 🌟
Examples
Example 1
words = ["duel", "speed", "dule", "cars"]queries = ["spede", "deul"]return = [["speed"], ["duel", "dule"]]
With words = ["duel", "speed", "dule", "cars"] and queries = ["spede", "deul"]:
- For "spede", the only anagram is "speed"
- For "deul", the anagrams are "duel" and "dule"
Return [["speed"], ["duel", "dule"]].
Constraints
1 ≤ n, q ≤ 50001 ≤ length of words[i], length of queries[i] ≤ 100- It is guaranteed that each query word has at least one anagram in words.
More JP Morgan Chase interview questions
- Longest Consecutive SequencePHONE SCREEN · Seen Nov 2026
- LFU CacheONSITE INTERVIEW · Seen Nov 2026
- LRU CacheONSITE INTERVIEW · Seen Nov 2026
- Find Total CostOA · Seen Oct 2026
- Minimum Meeting RoomsOA · Seen Oct 2026
- Count Dropped RequestsOA · Seen Oct 2026
- Maximize Binary XOR with a Set-Bit LimitPHONE SCREEN · Seen Oct 2026
- Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
- Task SchedulingOA · Seen Oct 2026
- Substring RemovalOA · Seen Oct 2026
Similar questions at other companies
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
- Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
- Flat JSON Value DifferencesChubb · OAChubb interview questions
- Lexicographic Word FrequenciesUpstart · OAUpstart interview questions
- Email Log Processing, Grouping, and SortingStripe · OAStripe interview questions
- Most Frequent CharacterMicrosoft · OAMicrosoft interview questions
- Get Maximum Information GainAmazon · OA
- Better CompressionGoldman Sachs · OAGoldman Sachs interview questions
- Process LogsSnowflake · OASnowflake interview questions
JP Morgan Chase interview experiences
- JPMorgan Chase Experienced SWE Java Interview: 1 Experience
- JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
- JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
- JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
- JP Morgan Chase Data and AI Intern Superday: 11 Experiences
- JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)