Problem statement:
You are given a set of k strings, each length n. You have to output the group of anagrams together. Anagrams are like e.g atm – mat , like-kile.
Problem statement: You are given a set of k strings, each length n. You
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just sort the word’s letters to obtain a signature that’s anagram-specific. E.g., in Python,
and make a
dictwithsigas the key and the value being a list of words with that signature (defaultdict(list)works well for this). Of course, you can do it in any language with sorting abilities, and associative arrays whose values can be lists or vectors;-).