题目
Given an array of strings, group anagrams together.
For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],
ouput:
[
[“ate”, “eat”,”tea”],
[“nat”,”tan”],
[“bat”]
]
思路
运用hashmap来解决
代码
1 | class Solution { |
ACG/东方厨/战锤粉
Given an array of strings, group anagrams together.
For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],
ouput:
[
[“ate”, “eat”,”tea”],
[“nat”,”tan”],
[“bat”]
]
运用hashmap来解决
1 | class Solution { |