Nav: << previous: 48.旋转图像 | next: 50.Pow(x, n) >>
Description
tab: English
<p>Given an array of strings <code>strs</code>, group the <span data-keyword="anagram">anagrams</span> together. You can return the answer in <strong>any order</strong>.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">strs = ["eat","tea","tan","ate","nat","bat"]</span></p>
<p><strong>Output:</strong> <span class="example-io">[["bat"],["nat","tan"],["ate","eat","tea"]]</span></p>
<p><strong>Explanation:</strong></p>
<ul>
<li>There is no string in strs that can be rearranged to form <code>"bat"</code>.</li>
<li>The strings <code>"nat"</code> and <code>"tan"</code> are anagrams as they can be rearranged to form each other.</li>
<li>The strings <code>"ate"</code>, <code>"eat"</code>, and <code>"tea"</code> are anagrams as they can be rearranged to form each other.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">strs = [""]</span></p>
<p><strong>Output:</strong> <span class="example-io">[[""]]</span></p>
</div>
<p><strong class="example">Example 3:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">strs = ["a"]</span></p>
<p><strong>Output:</strong> <span class="example-io">[["a"]]</span></p>
</div>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= strs.length <= 10<sup>4</sup></code></li>
<li><code>0 <= strs[i].length <= 100</code></li>
<li><code>strs[i]</code> consists of lowercase English letters.</li>
</ul>
---
[submissions](https://leetcode.com/problems/group-anagrams/submissions/) | [solutions](https://leetcode.com/problems/group-anagrams/solutions/)
tab: 中文
<p>给你一个字符串数组,请你将 <span data-keyword="anagram">字母异位词</span> 组合在一起。可以按任意顺序返回结果列表。</p>
<p> </p>
<p><strong>示例 1:</strong></p>
<div class="example-block">
<p><strong>输入:</strong> strs = ["eat", "tea", "tan", "ate", "nat", "bat"]</p>
<p><strong>输出: </strong>[["bat"],["nat","tan"],["ate","eat","tea"]]</p>
<p><strong>解释:</strong></p>
<ul>
<li>在 strs 中没有字符串可以通过重新排列来形成 <code>"bat"</code>。</li>
<li>字符串 <code>"nat"</code> 和 <code>"tan"</code> 是字母异位词,因为它们可以重新排列以形成彼此。</li>
<li>字符串 <code>"ate"</code> ,<code>"eat"</code> 和 <code>"tea"</code> 是字母异位词,因为它们可以重新排列以形成彼此。</li>
</ul>
</div>
<p><strong>示例 2:</strong></p>
<div class="example-block">
<p><strong>输入:</strong> strs = [""]</p>
<p><strong>输出: </strong>[[""]]</p>
</div>
<p><strong>示例 3:</strong></p>
<div class="example-block">
<p><strong>输入:</strong> strs = ["a"]</p>
<p><strong>输出: </strong>[["a"]]</p>
</div>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= strs.length <= 10<sup>4</sup></code></li>
<li><code>0 <= strs[i].length <= 100</code></li>
<li><code>strs[i]</code> 仅包含小写字母</li>
</ul>
---
[提交记录](https://leetcode.cn/problems/group-anagrams/submissions/) | [题解](https://leetcode.cn/problems/group-anagrams/solution/)
Solutions & Notes
properties:
note.updated:
displayName: Last Updated
note.relative_links:
displayName: Related Links
note.desc:
displayName: Description
note.grade:
displayName: Rating
note.program_language:
displayName: Language
note.time_complexity:
displayName: TC
note.space_complexity:
displayName: SC
views:
- type: table
name: Solutions & Notes
filters:
and:
- file.hasLink(this.file)
- file.tags.containsAny("leetcode/solution", "leetcode/note")
order:
- file.name
- desc
- program_language
- time_complexity
- space_complexity
- grade
- relative_links
- updated
sort:
- property: grade
direction: ASC
- property: time_complexity
direction: ASC
- property: program_language
direction: ASC
columnSize:
file.name: 104
note.space_complexity: 65
note.grade: 126
Similar Problems
properties:
note.lcTopics:
displayName: Topics
note.lcAcRate:
displayName: AC Rate
note.favorites:
displayName: Favorites
note.grade:
displayName: Rating
note.translatedTitle:
displayName: Title (CN)
note.lcDifficulty:
displayName: Difficulty
views:
- type: table
name: Similar Problems
filters:
and:
- file.hasLink(this.file)
- similarQuestions.contains(this.file)
order:
- file.name
- translatedTitle
- lcTopics
- lcDifficulty
- lcAcRate
- grade
- favorites
sort:
- property: file.name
direction: ASC
- property: lcTopics
direction: DESC
columnSize:
note.translatedTitle: 240
note.lcTopics: 347
note.lcAcRate: 75
note.grade: 122