There are millions of string in the database. How would you store them for efficient searching. You also need to print all anagrams together many times, now how would you store them and insert if a new string is added to database ?
Anagram: A word or phrase spelled by rearranging the letters of another word or phrase
Input:
"My one ym neo game ym"
Output:
{22231=[one, neo], 15334=[game], 3977=[My, ym]}
Anagram: A word or phrase spelled by rearranging the letters of another word or phrase
Input:
"My one ym neo game ym"
Output:
{22231=[one, neo], 15334=[game], 3977=[My, ym]}
But what is the case in larger strings
ReplyDeleteFor small set of data, map is used here, if required a repo/db can be used. Overall logic remains same but the implementation changes.
ReplyDelete