Skip to content

docs: update a description of the solution to lc problem: No.0049 #768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions solution/0000-0099/0049.Group Anagrams/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@

<!-- 这里可写通用的实现逻辑 -->

遍历字符串,将每个字符串按照字符字典序排序后得到一个新的字符串,将相同的新字符串放在哈希表的同一个 key 对应 value 列表中。
1. 遍历字符串,对每个字符串按照**字符字典序**排序,得到一个新的字符串。
2. 以新字符串为 `key`,`[str]` 为 `value`,存入哈希表当中(`HashMap<String, List<String>>`)。
3. 后续遍历得到相同 `key` 时,将其加入到对应的 `value` 当中即可。

以 `strs = ["eat", "tea", "tan", "ate", "nat", "bat"]` 为例,遍历结束时,哈希表的状况:

| key | value |
| ------- | ----------------------- |
| `"aet"` | `["eat", "tea", "ate"]` |
| `"ant"` | `["tan", "nat"] ` |
| `"abt"` | `["bat"] ` |

最后返回哈希表的 value 列表即可。
最后返回哈希表的 `value` 列表即可。

<!-- tabs:start -->

Expand Down