|
1 | | -<h2><a href="https://leetcode.com/problems/group-anagrams/">49. Group Anagrams</a></h2><h3>Medium</h3><hr><div><p>Given an array of strings <code>strs</code>, group <strong>the anagrams</strong> together. You can return the answer in <strong>any order</strong>.</p> |
2 | | - |
3 | | -<p>An <strong>Anagram</strong> is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.</p> |
| 1 | +<h2><a href="https://leetcode.com/problems/group-anagrams">49. Group Anagrams</a></h2><h3>Medium</h3><hr><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> |
4 | 2 |
|
5 | 3 | <p> </p> |
6 | 4 | <p><strong class="example">Example 1:</strong></p> |
7 | | -<pre><strong>Input:</strong> strs = ["eat","tea","tan","ate","nat","bat"] |
8 | | -<strong>Output:</strong> [["bat"],["nat","tan"],["ate","eat","tea"]] |
9 | | -</pre><p><strong class="example">Example 2:</strong></p> |
10 | | -<pre><strong>Input:</strong> strs = [""] |
11 | | -<strong>Output:</strong> [[""]] |
12 | | -</pre><p><strong class="example">Example 3:</strong></p> |
13 | | -<pre><strong>Input:</strong> strs = ["a"] |
14 | | -<strong>Output:</strong> [["a"]] |
15 | | -</pre> |
| 5 | + |
| 6 | +<div class="example-block"> |
| 7 | +<p><strong>Input:</strong> <span class="example-io">strs = ["eat","tea","tan","ate","nat","bat"]</span></p> |
| 8 | + |
| 9 | +<p><strong>Output:</strong> <span class="example-io">[["bat"],["nat","tan"],["ate","eat","tea"]]</span></p> |
| 10 | + |
| 11 | +<p><strong>Explanation:</strong></p> |
| 12 | + |
| 13 | +<ul> |
| 14 | + <li>There is no string in strs that can be rearranged to form <code>"bat"</code>.</li> |
| 15 | + <li>The strings <code>"nat"</code> and <code>"tan"</code> are anagrams as they can be rearranged to form each other.</li> |
| 16 | + <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> |
| 17 | +</ul> |
| 18 | +</div> |
| 19 | + |
| 20 | +<p><strong class="example">Example 2:</strong></p> |
| 21 | + |
| 22 | +<div class="example-block"> |
| 23 | +<p><strong>Input:</strong> <span class="example-io">strs = [""]</span></p> |
| 24 | + |
| 25 | +<p><strong>Output:</strong> <span class="example-io">[[""]]</span></p> |
| 26 | +</div> |
| 27 | + |
| 28 | +<p><strong class="example">Example 3:</strong></p> |
| 29 | + |
| 30 | +<div class="example-block"> |
| 31 | +<p><strong>Input:</strong> <span class="example-io">strs = ["a"]</span></p> |
| 32 | + |
| 33 | +<p><strong>Output:</strong> <span class="example-io">[["a"]]</span></p> |
| 34 | +</div> |
| 35 | + |
16 | 36 | <p> </p> |
17 | 37 | <p><strong>Constraints:</strong></p> |
18 | 38 |
|
|
21 | 41 | <li><code>0 <= strs[i].length <= 100</code></li> |
22 | 42 | <li><code>strs[i]</code> consists of lowercase English letters.</li> |
23 | 43 | </ul> |
24 | | -</div> |
|
0 commit comments