Group Anagrams - Getting Started / Warm Up

https://algo.monster/problems/group_anagrams

output exists the ordering of lines in a specific order, but this is not specified in the problem spec

Thank you for pointing out. We fixed the description.

Is it possible to get auto complete when using the editor in Java?

Using defaultdict(list) we can make the solution even cleaner!

Your Output
eat tea ate
tan nat
bat
Expected Output
ate eat tea
bat
nat tan

why are they not equal?

Can we please add boilerplate code for the Go language? :pleading_face:

Sure!

+1 for go

Already completed and submitted code is disappearing from code editor. could you check this ?

Can you elaborate? It might be that you cleared your browser cache.

Any way we could we add Ruby to the boilerplate code?

eat tea ate tan nat bat is not the same as
ate eat tea bat nat tan in terms of ordering

The C++ code is kinda broken. put_words is not defined and the main function tries to sort vectors without providing lambdas. I suggest leaving the task to generate the sorted vector of vectors to the user. I never expect to have to modify code generated by you, but I had to modify the main to this:

int main() {
std::vectorstd::string strs = get_wordsstd::string();
std::vector<std::vectorstd::string> res = group_anagrams(strs);
for (const std::vectorstd::string& row : res) {
put_words(row);
}
}

This is for the python code: If it is in the problem description to return the list of anagrams in alphabetical order, then why order the output for us in the driver code? If this was the actual question and I didn’t sort the output I would not pass the test cases.

Same problem here as Mike below was having: the C++ boilerplate is completely broken and doesn’t even compile!

Hi, thank you for pointing out. We’ve fixed it.

The tests are accepting the given solution, but the solution is wrong for the given specs.
Input: “eat tea tan ate nat bat”
Output as per specs: [[“ate”, “eat”, “tea”], [“bat”], [“nat”, “tan”]]
Output (from print statement) that pass the tests:

ate eat tea
bat
nat tan

(Also, make comment text-area widget resizable.)

Why is the runtime have mlog(m)? What produces the mlog(m)?

Sorting an array of size m is mlog(m).