Subscribed unsubscribe Subscribe Subscribe

Takefumi Yamamura's blog

This blog is for my memorandum.

Takefumi Yamamura's b!og

This blog is for my memorandum

Group Anagrams

就活 ソート bucket sort

problem

Write a method to sort an array of strings so that all the anagrams are next to each other.

how to solve

I use hash table. once we have grouped all the words into these lists by anagram. we can then put them back into the array.

code

Remove all ads