Given an array of strings, group anagrams together.
Example:
1
2
3
4
5
6
7
8 > Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
> Output:
> [
> ["ate","eat","tea"],
> ["nat","tan"],
> ["bat"]
> ]
>
Note:
- All inputs will be in lowercase.
- The order of your output does not matter.
sorted(String)
:return a sorted list of String
EX:
sorted('tae')
—> return['a', 'e', 't']
如果要反复访问,用
map
,比用list
遍历要快得多list(dic.values())
RES
1 | class Solution: |