Problem · String
Autocorrect Prototype
Complete the implementation of an autocorrect function. Given a search query string, the function should return all words which are anagrams.
Given 2 arrays, words[n], and queries[q], for each
query, return an array of the strings that are anagrams, sorted alphabetically ascending.
Note: An anagram is any string that can be formed be rearranging the letters of a string.
Complete the function getSearchResults in the editor.
Examples
01 · Example 1
n = 2 words = ["duel", "speed", "dule", "cars"] queries = ["dpede", "deul"] return = [["speed"], ["duel", "dule"]]
The only anagram of "speed" is "spede".
Both "duel" and "dule" are anagrams of "deul".
Return [["speed"], ["duel", "dule"]].
Constraints
More Goldman Sachs problems
public String[][] autocorrectPrototype(int n, String[] words, String[] queries) {
// write your code here
}
n2
words["duel", "speed", "dule", "cars"]
queries["dpede", "deul"]
expected[["speed", "duel", "dule"]]
checking account