Skip to content

Commit 430c54a

Browse files
authored
docs: update a description of the solution to lc problem: No.0049 (#768)
1 parent 093a0b6 commit 430c54a

File tree

1 file changed

+6
-2
lines changed
  • solution/0000-0099/0049.Group Anagrams

1 file changed

+6
-2
lines changed

solution/0000-0099/0049.Group Anagrams/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,19 @@
4545

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

48-
遍历字符串,将每个字符串按照字符字典序排序后得到一个新的字符串,将相同的新字符串放在哈希表的同一个 key 对应 value 列表中。
48+
1. 遍历字符串,对每个字符串按照**字符字典序**排序,得到一个新的字符串。
49+
2. 以新字符串为 `key``[str]``value`,存入哈希表当中(`HashMap<String, List<String>>`)。
50+
3. 后续遍历得到相同 `key` 时,将其加入到对应的 `value` 当中即可。
51+
52+
`strs = ["eat", "tea", "tan", "ate", "nat", "bat"]` 为例,遍历结束时,哈希表的状况:
4953

5054
| key | value |
5155
| ------- | ----------------------- |
5256
| `"aet"` | `["eat", "tea", "ate"]` |
5357
| `"ant"` | `["tan", "nat"] ` |
5458
| `"abt"` | `["bat"] ` |
5559

56-
最后返回哈希表的 value 列表即可。
60+
最后返回哈希表的 `value` 列表即可。
5761

5862
<!-- tabs:start -->
5963

0 commit comments

Comments
 (0)