LeetCode 49. Group Anagrams
2020-06-25 20:03:38
# leetcode
# core problems
# medium
Problem
1. 题目简述
给出一组字符串(全部由小写字母组成),将由相同字母组成的字符串按组进行返回。例如:
Example:
Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
Output:
[
["ate","eat","tea"],
["nat","tan"],
["bat"]
]
2. 算法思路
其实这道题是很直接的一道题,问题就在于统计anagram,如何才能判断两个字符串啊anagram。这里我们用一个很巧妙的hash方法,记录每个字符串组成字母的哈希值。如下:
hashtable
1 | class Solution { |