# 【LeetCode】49. Group Anagrams

Given an array of strings, group anagrams together.

For example, given: `["eat", "tea", "tan", "ate", "nat", "bat"]`
Return:

```[
["ate", "eat","tea"],
["nat","tan"],
["bat"]
]
```

```1 class Solution(object):
2     def groupAnagrams(self, strs):
3         """
4         :type strs: List[str]
5         :rtype: List[List[str]]
6         """
7         return [sorted(x) for _,x in itertools.groupby(sorted(strs, key=sorted),key=sorted)]```

``` 1 class Solution(object):
2     def groupAnagrams(self, strs):
3         """
4         :type strs: List[str]
5         :rtype: List[List[str]]
6         """
7         dd = collections.defaultdict(list)
8         for s in strs:
9             dd[tuple(sorted(s))].append(s)
10         return map(sorted, dd.values())```

## LeetCode开心刷题二十六天——49.Group Anagrams

49. Group Anagrams Medium 1824116FavoriteShare Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat

## 【LeetCode】哈希表 hash_table（共88题）

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica } [1]Two Sum (2018年11月9日,k-sum专题,算法群衍生题) 给了一个数组 nums, 和一个 target 数字,要求返回一个下标的 pair, 使得这两个元素相加等于 target . 题解:我这次最大范围的优化代码, hash-table + one pass,时间复杂度 O(N),空间复杂度 O(N).重点在于动态找,一边生成hash-tabl

## 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java

[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 递归和非递归,此提比较简单.广度优先遍历即可.关键之处就在于如何保持访问深度. 下面是4种代码: 1

## 【leetcode】893. Groups of Special-Equivalent Strings

Algorithm [leetcode]893. Groups of Special-Equivalent Strings https://leetcode.com/problems/groups-of-special-equivalent-strings/ 1)problem You are given an array A of strings. Two strings S and T are special-equivalent if after any number of moves,

## 【LeetCode】Implement strStr()

Implement strStr() Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. 标准KMP算法.可参考下文. http://blog.csdn.net/yaochunnian/article/details/7059486 核心思想在于求出模式串前缀与后缀中重复部分,将重复信息保存在n

## 【LeetCode】Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. Input: (2 -> 4 -> 3) + (5 -> 6 ->